XML Schema problem

Moritz Petersen <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Message-ID <[email protected]>
Hello everyone,

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.

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:

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.

The test code is the same for each test:

     protected void assertXsdValid(Source xsdSource, InputSource  
xmlInputSource) throws SAXException, ParserConfigurationException,  
IOException {
         isValid = true;
         SchemaFactory sf =  
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
         sf.setErrorHandler(myErrorHandler);
         Schema schema = sf.newSchema(xsdSource); // <<--- Here it  
fails!!
         DocumentBuilderFactory dbf =  
DocumentBuilderFactory.newInstance();
         dbf.setNamespaceAware(true);
         dbf.setSchema(schema);
         DocumentBuilder db = dbf.newDocumentBuilder();
         db.setErrorHandler(myErrorHandler);
         db.parse(xmlInputSource); // sets the isValid field to false  
if validation fails
         assertTrue(isValid);
     }

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:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://some.org/metamodel"  
elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema 
">
   <xs:element name="system">
     <xs:complexType>
       <xs:sequence>
         <xs:element name="name" type="xs:string"/>
         <xs:element name="vendor" type="xs:string"/>
         <xs:element name="version" type="xs:decimal"/>
       </xs:sequence>
     </xs:complexType>
   </xs:element>
</xs:schema>

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.

Thank you.

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.