Michael, > If you're willing to stray a little away from writing pure JAXP code, you > may be able to achieve what you want by setting the > "http://apache.org/xml/features/internal/validation/schema/use-grammar-pool-only" > feature to false on the SchemaFactory.
It looks like that particular feature is not supported by the internal Xerces bundled in Java5. A small example of my problem: <code> XMLStreamReader reader = XMLInputFactory.newInstance() .createXMLStreamReader(new FileInputStream(new File("test/input.xml"))); // Create the new builder StAXOMBuilder builder = new StAXOMBuilder(reader); // Get the document element OMElement omElement = builder.getDocumentElement(); // LLOM to DOOM XMLStreamReader llomReader = omElement.getXMLStreamReader(); // Create the DOOM OMFactory OMFactory doomFactory = DOOMAbstractFactory.getOMFactory(); StAXOMBuilder doomBuilder = new StAXOMBuilder(doomFactory, llomReader); OMElement newElement = doomBuilder.getDocumentElement(); SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = factory.newSchema(); Validator validator = schema.newValidator(); validator.setResourceResolver(new LSResourceResolver() { public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { System.err.println("Resolving: " + type + ";" + namespaceURI + ";" + publicId + ";" + systemId + ";" + baseURI); return null; } }); validator.validate(new DOMSource((Element) newElement)); </code> Schema: <?xml version="1.0" encoding="UTF-8"?> <schema targetNamespace="http://jpinto.homeip.net/2007/07/agentplatform" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ap="http://jpinto.homeip.net/2007/07/agentplatform" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd" /> <element name="Message" type="ap:MessageType" /> <complexType name="MessageType"> <sequence> <element name="Receiver" minOccurs="0" maxOccurs="unbounded" type="ds:X509DataType" /> <any namespace="##other" processContents="strict" /> </sequence> </complexType> </schema> XML instance: <?xml version="1.0" encoding="UTF-8"?> <ap:Message xmlns:ap="http://jpinto.homeip.net/2007/07/agentplatform" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xsi:schemaLocation="http://jpinto.homeip.net/2007/07/agentplatform http://jpinto.homeip.net/~jpinto/metaagent.xsd "> <wsdl:definitions /> </ap:Message> (WSDL schema reference used as a test example). Exception got: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'wsdl:definitions'. The resolver is never called. > You could do that, though if there's no technical reason why you need to > pre-compile the "base" schema SchemaFactory.newSchema() [1] would work as > well and would avoid any Xerces specific features. The only technical reason is eficiency, since validation will be a recurring task and the overhead of re-compiling the schema in each and every call might be significative. I am feeling a bit overwhelmed by the prospect of having to implement a full caching structure for schemas and having to reprocess the top schema every time to keep standard for a "trivial" task like validation :-) . Any thoughts or should I move forward? Thanks, João -- O Insurgente - http://oinsurgente.org Small Brother - http://small-brother.blogspot.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]