Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
XML Schema problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

XML Schema problem



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.

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.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.