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]

Reply via email to