XSD 1.1 Not Supported in JDK 13

This section provides a tutorial example to verify is the default JAXP implementation in the current JDK version supports XSD 1.1 or not. The answer is no for JDK 13.

One more question we have to answer before we leave this chapter about JAXP API as an XSD (XML Schema) processor is: Does the current version of JDK support XSD 1.1 specification?

The answer is no for JDK 13. We can prove this by trying to load this simple XSD 1.1 schema document, xsd11_datatype_test.xsd, with we used earlier in this chapter:

herong> type xsd11_datatype_test.xsd

< ?xml version="1.1"?>
< xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
< !-- xsd11_datatype_test.xsd
 - Copyright (c) 2013 HerongYang.com. All Rights Reserved.
-->
< xs:element name="XSD11_Datatype_Test">
  < xs:complexType>
    < xs:sequence>
      <xs:element name="XSD10Type" type="xs:string"
        maxOccurs="unbounded"/>
      < xs:element name="AnyAtomicType" type="xs:anyAtomicType"
        maxOccurs="unbounded"/>
      < xs:element name="DateTimeStamp" type="xs:dateTimeStamp"
        maxOccurs="unbounded"/>
      < xs:element name="DayTimeDuration" type="xs:dayTimeDuration"
        maxOccurs="unbounded"/>
      < xs:element name="YearMonthDuration" type="xs:yearMonthDuration"
        maxOccurs="unbounded"/>
    < /xs:sequence>
  < /xs:complexType>
< /xs:element>
< /xs:schema>


herong> java XsdSchemaLoader.java xsd11_datatype_test.xsd

Schema Language: http://www.w3.org/2001/XMLSchema
Factory Class: com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory

org.xml.sax.SAXParseException; systemId: file:/herong/xsd/xsd11_datatype_test.xsd;
  lineNumber: 12; columnNumber: 32; src-resolve.4.2: Error resolving component
  'xs:anyAtomicType'. It was detected that 'xs:anyAtomicType' is in namespace
  'http://www.w3.org/2001/XMLSchema', but components from this namespace are
  not referenceable from schema document 'file:/herong/xsd/xsd11_datatype_test.xsd'.
  If this is the incorrect namespace, perhaps the prefix of 'xs:anyAtomicType'
  needs to be changed. If this is the correct namespace, then an appropriate
  'import' tag should be added to 'file:/herong/xsd/xsd11_datatype_test.xsd'.

As you can see, the definition first child element loaded ok, because it uses xs:string, which is an XSD 1.0 datatype. The definition of the second child element failed to load, because it uses xs:anyAtomicType, which is XSD 1.1 datatype.

Also note that the error message is very confusing: "It was detected that 'xs:anyAtomicType' is in namespace 'http://www.w3.org/2001/XMLSchema', but components from this namespace are not referenceable from schema document...". It could be very simple as: "'xs:anyAtomicType' is undefined."

Table of Contents

 About This Book

 Introduction to XML Schema

 XML Editor and Schema Processor - XMLPad

 Java API for XML Processing - JAXP

JAXP - XML Schema (XSD) Validation

 Standard Steps to Validate XML Documents Against a Schema

 XSD Schema File Loader - XsdSchemaLoader.java

 XSD Schema File Loading Errors

 XSD Schema XML DOM Validator - XsdSchemaDomValidator.java

 XSD Schema XML DOM Validation Errors

 XSD Schema XML DOM Validator with Error Handler

 XSD Schema XML SAX Validator - XsdSchemaSaxValidator.java

 XSD Schema XML SAX Validation Errors

 XSD Schema XML SAX Validator with Error Handler

 XSD Schema XML Validator - Final Version

XSD 1.1 Not Supported in JDK 13

 Xerces2 Java Parser - Java API of XML Parsers

 Using Xerces2 Java APIs

 XML Schema Language - Basics

 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

 Complex Element Declaration

 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

 Linking Multiple Schema Documents Together

 Glossary

 Archived Tutorials

 References

 Full Version in PDF/EPUB