[jdom-interest] XML Schema problem

Moritz Petersen mail at moritzpetersen.de
Wed Mar 25 14:39:08 PDT 2009

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  

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 =  
         Schema schema = sf.newSchema(xsdSource); // <<--- Here it  
         DocumentBuilderFactory dbf =  
         DocumentBuilder db = dbf.newDocumentBuilder();
         db.parse(xmlInputSource); // sets the isValid field to false  
if validation fails

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:element name="name" type="xs:string"/>
         <xs:element name="vendor" type="xs:string"/>
         <xs:element name="version" type="xs:decimal"/>

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20090325/2bf013cd/attachment.htm

More information about the jdom-interest mailing list