This section describes the built-in primitive datatype, 'NOTATION' that represents custom defined notations to describe non-XML data formats. Whitespaces are allowed and removed.
"NOTATION" is a built-in datatype that represents custom defined notations
to describe non-XML data formats
with these rules:
The value space of "NOTATION" contains all notations defined in the XSD document.
The lexical space of "NOTATION" contains all notation names defined in the XSD document.
Leading and trailing whitespaces allowed and trimmed.
"NOTATION" datatype must be used indirectly through an "enumeration" custom datatype constructed
from the "NOTATION" datatype.
To verify these rules, I wrote the first XSD document trying to use "NOTATION" directly:
Running my XsdSchemaValidator.java program presented earlier in the book,
I get this error:
c:\Progra~1\Java\jdk1.7.0_07\bin\java XsdSchemaValidator
NOTATION_datatype_test_invalid_1.xsd any.xml
org.xml.sax.SAXParseException; systemId:
file:/C:/herong/NOTATION_datatype_test_invalid_1.xsd;
lineNumber: 10; columnNumber: 30;
enumeration-required-notation: The NOTATION type, 'NOTATION' used by
element 'NOTATION', must have an enumeration facet value which
specifies the notation elements used by this type.
java.lang.NullPointerException
In the second XSD document, I tried to construct an "enumeration" custom datatype based on
"NOTATION" referring to an undefined notation name:
Here is a sample XML document that can be used to test this XSD document:
<?xml version="1.1"?>
<!-- NOTATION_datatype_test.xml
- Copyright (c) 2013, HerongYang.com, All Rights Reserved.
-->
<NOTATION_Datatype_Test>
<!-- 3 valid "NOTATION" elements -->
<NOTATION> jpg </NOTATION>
<NOTATION> wav </NOTATION>
<!-- 3 invalid "NOTATION" elements -->
<NOTATION> mp3 </NOTATION>
</NOTATION_Datatype_Test>
When validating this XML document with my XsdSchemaValidator.java program,
I get 1 group of errors for 1 invalid XML element:
c:\Progra~1\Java\jdk1.7.0_07\bin\java XsdSchemaValidator
NOTATION_datatype_test_valid.xsd NOTATION_datatype_test.xml
Error:
Line number: 12
Column number: 34
Message: cvc-enumeration-valid: Value 'mp3' is not facet-valid with
respect to enumeration '[jpg, gif, wav]'. It must be a value from
the enumeration.
Error:
Line number: 12
Column number: 34
Message: cvc-type.3.1.3: The value ' mp3 ' of element
'NOTATION' is not valid.
Failed with errors: 2