XSD Tutorials - Herong's Tutorial Examples - v5.23, by Herong Yang
XSD 1.1 not Supported by sax.Writer
This section provides a tutorial example showing that sax.Writer does not support XSD 1.1.
As you can see from tests in the previous section, sax.Writer can be used as a nice validation tool on XML documents associated with an XSD schema.
Now I want to see if sax.Writer supports XSD 1.1 or not:
herong> type hello_xsd11.xsd <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="p" type="xsd:anyAtomicType"/> </xsd:schema> herong> type hello_xsd11.xml <?xml version="1.0"?> <p xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="hello_xsd11.xsd"> Hello world!</p> herong> java_xerces sax.Writer -v -s hello_xsd11.xml [Error] hello_xsd11.xsd:3:50: src-resolve.4.2: Error resolving ^^^ component 'xsd:anyAtomicType'. It was detected that ^^^ 'xsd:anyAtomicType' is in namespace ^^^ 'http://www.w3.org/2001/XMLSchema', but components from this ^^^ namespace are not referenceable from schema document ^^^ 'file:///C:/herong/hello_xsd11.xsd'. If this is the incorrect ^^^ namespace, perhaps the prefix of 'xsd:anyAtomicType' needs to be ^^^ changed. If this is the correct namespace, then an appropriate ^^^ 'import' tag should be added to ^^^ 'file:///C:/herong/hello_xsd11.xsd'. [Error] hello_xsd11.xsd:3:50: src-resolve: Cannot resolve the name ^^^ 'xsd:anyAtomicType' to a(n) 'type definition' component. <?xml version="1.0" encoding="UTF-8"?> <p xsi:noNamespaceSchemaLocation="hello_xsd11.xsd"> Hello world!</p>
Too bad, sax.Writer does not support XSD 1.1. As you can see, the new datatype xsd:anyAtomicType introduced in XSD 1.1 is not recognized.
Table of Contents
XML Editor and Schema Processor - XMLPad
Java API for XML Processing - JAXP
JAXP - XML Schema (XSD) Validation
►Xerces2 Java Parser - Java API of XML Parsers
Installing Xerces2 Java Parser for XSD 1.1
Verify Installation of Xerces2
Xerces2 Sample Program dom.Counter
dom.Counter Validating XML with Associated XSD
dom.GetElementsByTagName and dom.Writer
sax.DocumentTracer and sax.Writer
Examples of XSD and XML Files with Errors
sax.Writer Reporting Errors Embedded in XML Structure
►XSD 1.1 not Supported by sax.Writer
XSD 1.1 Supported by jaxp.SourceValidator
Examples of XSD 1.1 and XML Files with Errors
jaxp.TypeInfoWriter as an XSD 1.1 Validation Tool
Introduction of XSD Built-in Datatypes
"string" and Its Derived Datatypes
"decimal" and Its Derived Datatypes
"dateTime" and Its Related Datatypes
Miscellaneous Built-in Datatypes
Facets, Constraining Facets and Restriction Datatypes
"simpleType" - Defining Your Own Simple Datatypes
Identity-Constraints: unique, key and keyref
Assertion as Custom Validation Rules
XML Schema Location and Namespace in XML Documents
Overriding Element Types in XML Documents