DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7735>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7735 Schema validation errors with xmlns attributes Summary: Schema validation errors with xmlns attributes Product: Xerces2-J Version: 2.0.1 Platform: All OS/Version: All Status: NEW Severity: Normal Priority: Other Component: XML Schema Structures AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] I am using JDOM beta 8 and xerces underneath to build a validating parser for some xml and schema files. Previously, I was using JDOM beta 7 with xerces 1.3.1. I have a schema with the following as the start of the definition: <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" targetNamespace="http://www.mitec.net/~dennison/mud/v1" xmlns="http://www.mitec.net/~dennison/mud/v1" elementFormDefault="qualified"> ... I have an XML file with the following as the root element: <jmud xmlns="http://www.mitec.net/~dennison/mud/v1" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:schemaLocation="http://www.mitec.net/~dennison/mud/v1 C:\projects\jmud\src\content\xsd\jmud.xsd"> ... I am using qualified namespaces and no problems with validation under xerces 1.3.1. Upon upgrading to 2.0.1 I encountered two errors. The first error: org.xml.sax.SAXParseException: Document root element "jmud", must match DOCTYPE root "null". at org.apache.xerces.parsers.AbstractSAXParser.parse (AbstractSAXParser.java:1163) at org.jdom.input.SAXBuilder.build(SAXBuilder.java:354) at org.jdom.input.SAXBuilder.build(SAXBuilder.java:673) at net.mitec.dennison.app.jmud.parse.ParseConfigFile.buildDocument (ParseConfigFile.java:285) ... I resolved this problem by adding the following line of code in my source code: builder.setFeature("http://apache.org/xml/features/validation/schema", true); Why is it necessary to add this line and why doesn't xerces recognize that a schema is being used for validation? The next error I received was this: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'jmud'. at org.apache.xerces.parsers.AbstractSAXParser.parse (AbstractSAXParser.java:1163) at org.jdom.input.SAXBuilder.build(SAXBuilder.java:354) at org.jdom.input.SAXBuilder.build(SAXBuilder.java:673) ... It turns out this problem involves the xmlns attribute: In the schema: <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" ... In the xml: <jmud xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" ... Changing those lines in the schema and XML to: In the schema: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" ... In the xml: <jmud xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ... fixes the problem. Are we required to change all schemas and xml files to the 2001 namespaces to use xerces 2.0.1? --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
