Hi Jack,

What you're getting from JDK 1.5 (com.sun.org.apache.xerces.internal.*) is
Sun's two to three year old fork off the Xerces codebase. This predates the
JAXP 1.3 implementation in Xerces and has bugs which are unique to it and
others which have long been fixed in Apache.

My advice to you would be to download the latest version of Xerces-J (which
is 2.9.1) and try running your application again. One bug [1] in some
versions of the JDK prevents Xerces' SchemaFactory implementation from
being loaded normally. Using the Endorsed Standards Override Mechanism
[2][3] (with xml-apis.jar and xercesImpl.jar) will resolve that.

Thanks.

[1] http://marc.info/?l=xml-commons-dev&m=111898640501739&w=2
[2] http://xerces.apache.org/xerces2-j/faq-general.html#faq-4
[3] http://java.sun.com/j2se/1.5.0/docs/guide/standards/

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

Jack Ferrod <[EMAIL PROTECTED]> wrote on 11/16/2007 08:45:01 AM:

> Hi all,
>
> I want to validate a bit of XML that is built up of various embedded
> documents that all have their own little schema (it's actually a WS-
> Policy document). I would like to obtain the PVI after the
> validation so I can read out the defaults that may be present in the
> schemas. Because I don't know all the schemas used in the document
> in advance, I would like to resolve them as needed, so for that I
> want to use a LSResourceResolver object that I set on my Validator.
> However, my resolver doesn't get called back.
>
> I have the following bit of code:
> SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.
> W3C_XML_SCHEMA_NS_URI);
> Schema schema = factory.newSchema();
> Validator validator = schema.newValidator();
> validator.setResourceResolver(new MyResourceResolver()); // my own
resolver
> DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> dbf.setNamespaceAware(true);
> DocumentBuilder parser = dbf.newDocumentBuilder();
> Document document = parser.parse(new ByteArrayInputStream(xmlDoc.
> getBytes())); // my document is in the xmlDoc string
> DOMResult result = new DOMResult();
> validator.validate(new DOMSource(document), result);
> // at this point I want to start using the PVI
>
> Now at this point my 'MyResourceResolver' didn't get called. I'm
> using JDK 1.5.
> From debugging into it, I noticed that I find myself in the
> com.sun.org.apache.xerces.internal.impl.XMLEntityManager class in
> the resolveEntity() method, but the fEntityResolver member variable
> is null, so its not calling MyResourceResolver back.
>
> Anyone any ideas on how to achieve what I need?
>
> Thanks,
>
> Jack
>
> BTW MyResourceResolver is just like this:
> private static class MyResourceResolver implements LSResourceResolver {
>   public LSInput resolveResource(String type, String namespaceURI,
> String publicId, String systemId, String baseURI) {
>     System.out.println("### resolveResource: " + type + "£" +
> namespaceURI + "£" + publicId + "£" + systemId + "£" + baseURI);
>     return null;
>   }
> }
>
>
>
> ___________________________________________________________
> NEW Yahoo! Cars - sell your car and browse thousands of new and used
> cars online! http://uk.cars.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to