<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello everyone,<div><br></div><div>I've run into a strange problem. In my project I experimented a bit with XML Schema validation. I use 4 approaches to generate XML and XML Schema documents: Files (both documents exist as actual XML files), JDOM (both documents get generated with JDOM), dom4j and XOM.</div><div><br></div><div>Why am I posting to this list? I started development on a Windows machine. All my tests run smoothly on that machine. When installing the same project on my old Mac (PowerBook G4, Mac OS X 10.5.6, java version "1.5.0_16"), both tests for JDOM and dom4j fail with the same error:</div><div><br></div><div><div>org.xml.sax.SAXParseException: s4s-att-invalid-value: Invalid attribute value for 'type' in element 'element'. Recorded reason: UndeclaredPrefix: Cannot resolve 'xs:decimal' as a QName: the prefix 'xs' is not declared.</div><div><br></div><div>The test code is the same for each test:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: rgb(127, 0, 85); ">protected</span> <span style="color: rgb(127, 0, 85); ">void</span> assertXsdValid(Source xsdSource, InputSource xmlInputSource) <span style="color: rgb(127, 0, 85); ">throws</span> SAXException, ParserConfigurationException, IOException {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: rgb(0, 0, 192); ">isValid</span> = <span style="color: rgb(127, 0, 85); ">true</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.<span style="color: rgb(0, 0, 192); ">W3C_XML_SCHEMA_NS_URI</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> sf.setErrorHandler(<span style="color: rgb(0, 0, 192); ">myErrorHandler</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> Schema schema = sf.newSchema(xsdSource); // <<--- Here it fails!!</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> dbf.setNamespaceAware(<span style="color: rgb(127, 0, 85); ">true</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> dbf.setSchema(schema);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> DocumentBuilder db = dbf.newDocumentBuilder();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> db.setErrorHandler(<span style="color: rgb(0, 0, 192); ">myErrorHandler</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> db.parse(xmlInputSource); // sets the isValid field to false if validation fails</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> assertTrue(<span style="color: rgb(0, 0, 192); ">isValid</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> }</div></div><div><br></div><div>The strange thing is, that if I copy the JDOM generated XSD file into the XSD file of the "file test" (see above), then the "file test" does not fail. This is how the XSD file looks like:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(127, 0, 127); "><span style="color: #008080"><?</span><span style="color: #3f7f7f">xml</span><span style="color: #000000"> </span>version<span style="color: #000000">=</span><span style="color: #2a00ff">"1.0"</span><span style="color: #000000"> </span>encoding<span style="color: #000000">=</span><span style="color: #2a00ff">"UTF-8"</span><span style="color: #008080">?></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(42, 0, 255); "><span style="color: #008080"><</span><span style="color: #3f7f7f">xs:schema</span><span style="color: #000000"> </span><span style="color: #7f007f">targetNamespace</span><span style="color: #000000">=</span>"<a href="http://some.org/metamodel">http://some.org/metamodel</a>"<span style="color: #000000"> </span><span style="color: #7f007f">elementFormDefault</span><span style="color: #000000">=</span>"qualified"<span style="color: #000000"> </span><span style="color: #7f007f">xmlns:xs</span><span style="color: #000000">=</span>"<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a>"<span style="color: #008080">></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(63, 127, 127); "><span style="color: #000000"> </span><span style="color: #008080"><</span>xs:element<span style="color: #000000"> </span><span style="color: #7f007f">name</span><span style="color: #000000">=</span><span style="color: #2a00ff">"system"</span><span style="color: #008080">></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(63, 127, 127); "><span style="color: #000000"> </span><span style="color: #008080"><</span>xs:complexType<span style="color: #008080">></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(63, 127, 127); "><span style="color: #000000"> </span><span style="color: #008080"><</span>xs:sequence<span style="color: #008080">></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(42, 0, 255); "><span style="color: #000000"> </span><span style="color: #008080"><</span><span style="color: #3f7f7f">xs:element</span><span style="color: #000000"> </span><span style="color: #7f007f">name</span><span style="color: #000000">=</span>"name"<span style="color: #000000"> </span><span style="color: #7f007f">type</span><span style="color: #000000">=</span>"xs:string"<span style="color: #008080">/></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(42, 0, 255); "><span style="color: #000000"> </span><span style="color: #008080"><</span><span style="color: #3f7f7f">xs:element</span><span style="color: #000000"> </span><span style="color: #7f007f">name</span><span style="color: #000000">=</span>"vendor"<span style="color: #000000"> </span><span style="color: #7f007f">type</span><span style="color: #000000">=</span>"xs:string"<span style="color: #008080">/></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(42, 0, 255); "><span style="color: #000000"> </span><span style="color: #008080"><</span><span style="color: #3f7f7f">xs:element</span><span style="color: #000000"> </span><span style="color: #7f007f">name</span><span style="color: #000000">=</span>"version"<span style="color: #000000"> </span><span style="color: #7f007f">type</span><span style="color: #000000">=</span>"xs:decimal"<span style="color: #008080">/></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(63, 127, 127); "><span style="color: #000000"> </span><span style="color: #008080"></</span>xs:sequence<span style="color: #008080">></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(63, 127, 127); "><span style="color: #000000"> </span><span style="color: #008080"></</span>xs:complexType<span style="color: #008080">></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(63, 127, 127); "><span style="color: #000000"> </span><span style="color: #008080"></</span>xs:element<span style="color: #008080">></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(63, 127, 127); "><span style="color: #008080"></</span>xs:schema<span style="color: #008080">></span></div><div><br></div></div><div>I can't help but guessing that this might be some Mac related issue, but I cannot figure out what it might be. Maybe someone in this list can help me out.</div><div><br></div><div>Thank you.</div></div></div></body></html>