∟jaxp.TypeInfoWriter as an XSD 1.1 Validation Tool
This section provides a tutorial example on how to use sample program jaxp.TypeInfoWriter as an XSD 1.1 validation tool. It prints out element type information, while it is parsing through the XML document. Error messages are printed out where and when they occurred.
If you want to see XSD 1.1 errors printed inside the XML element structure,
you can try the other sample program, jaxp.TypeInfoWriter:
>jdk8x2r jaxp.TypeInfoWriter -xsd11 -i xsd11_datatype_test.xml
setDocumentLocator(systemId="file:///C:/herong
^^^ /xsd11_datatype_test.xml", publicId=null)
startDocument()
startElement(name="XSD11_Datatype_Test",type=
^^^ "#AnonType_XSD11_Datatype_Test",attributes={{name=
^^^ "{http://www.w3.org/2001/XMLSchema-instance}
^^^ noNamespaceSchemaLocation",type="{http://www.w3.org/2001
^^^ /XMLSchema}anyURI",id="false",specified="true"}})
startElement(name="AnyAtomicType",type="{http://www.w3.org/2001
^^^ /XMLSchema}anyAtomicType",attributes={})
endElement(name="AnyAtomicType")
startElement(name="AnyAtomicType",type="{http://www.w3.org/2001
^^^ /XMLSchema}anyAtomicType",attributes={})
endElement(name="AnyAtomicType")
startElement(name="AnyAtomicType",type="{http://www.w3.org/2001
^^^ /XMLSchema}anyAtomicType",attributes={})
endElement(name="AnyAtomicType")
startElement(name="AnyAtomicType",type="{http://www.w3.org/2001
^^^ /XMLSchema}anyAtomicType",attributes={})
startElement(name="b",type="{http://www.w3.org/2001/XMLSchema}
^^^ anyType",attributes={{name="size",type=null,id="false",
^^^ specified="true"}})
endElement(name="b")
[Error] xsd11_datatype_test.xml:17:67: cvc-type.3.1.2: Element
^^^ 'AnyAtomicType' is a simple type, so it must have no element
^^^ information item [children].
endElement(name="AnyAtomicType")
startElement(name="DateTimeStamp",type="{http://www.w3.org/2001
^^^ /XMLSchema}anyAtomicType",attributes={})
endElement(name="DateTimeStamp")
startElement(name="DateTimeStamp",type="{http://www.w3.org/2001
^^^ /XMLSchema}anyAtomicType",attributes={})
[Error] xsd11_datatype_test.xml:23:51: cvc-datatype-valid.1.2.1: '?'
^^^ is not a valid value for 'dateTimeStamp'.
[Error] xsd11_datatype_test.xml:23:51: cvc-type.3.1.3: The value
^^^ ' ? ' of element 'DateTimeStamp' is not valid.
endElement(name="DateTimeStamp")
startElement(name="DayTimeDuration",type="{http://www.w3.org/2001
^^^ /XMLSchema}anyAtomicType",attributes={})
endElement(name="DayTimeDuration")
startElement(name="DayTimeDuration",type="{http://www.w3.org/2001
^^^ /XMLSchema}dayTimeDuration",attributes={})
[Error] xsd11_datatype_test.xml:29:65: cvc-datatype-valid.1.2.1:
^^^ 'P1Y2M3DT5H20M30.123S' is not a valid value for 'dayTimeDuration'.
[Error] xsd11_datatype_test.xml:29:65: cvc-type.3.1.3: The value
^^^ ' P1Y2M3DT5H20M30.123S ' of element 'DayTimeDuration' is not
^^^ valid.
endElement(name="DayTimeDuration")
startElement(name="YearMonthDuration",type="{http://www.w3.org/2001
^^^ /XMLSchema}yearMonthDuration",attributes={})
endElement(name="YearMonthDuration")
startElement(name="YearMonthDuration",type="{http://www.w3.org/2001
^^^ /XMLSchema}yearMonthDuration",attributes={})
[Error] xsd11_datatype_test.xml:35:69: cvc-datatype-valid.1.2.1:
^^^ 'P1Y2M3DT5H20M30.123S' is not a valid value for
^^^ 'yearMonthDuration'.
[Error] xsd11_datatype_test.xml:35:69: cvc-type.3.1.3: The value
^^^ ' P1Y2M3DT5H20M30.123S ' of element 'YearMonthDuration' is
^^^ not valid.
endElement(name="YearMonthDuration")
endElement(name="XSD11_Datatype_Test")
endDocument()
Excellent! jaxp.TypeInfoWriter is good XSD 1.1 validation tool.
It prints out element type information,
while it is parsing through the XML document.
Error messages are printed out where and when they occurred.