Datasheet
53: e.printStackTrace();
54: }
55: }
56: }
Additional Schema Checking
The feature http://apache.org/xml/features/validation/schema-full-checking turns on additional
checking for schema documents. This doesn’t affect documents using the schema but does more thor-
ough checking of the schema document itself, in particular particle unique attribute constraint checking
and particle derivation restriction checks. This feature is normally set to false because these checks are
resource intensive.
Schema-Normalized Values
Element content is also normalized when you validate with XML Schema (only attribute values were
normalized in XML 1.0). The reason is that simple types can be used as both element content and
attribute values, so element content must be treated the same as attribute values in order to obtain the
same semantics for simple types. In Xerces, the feature http://apache.org/xml/features/validation
/schema/normalized-value controls whether SAX and DOM see the Schema-normalized values of ele-
ments and attributes or the XML 1.0 infoset values of elements and attributes. If you’re validating with
XML Schema, this feature is normally turned on.
Reporting Default Values
In XML Schema, elements and attributes are similar in another way: They can both have default values.
The question then arises, how should default values be reported to the application? Should the parser
assume the application knows what the default value is, or should the parser provide the default
value to the application? The only downside to the parser providing the default value is that if the
application knows what the default value is, the parser is doing unnecessary work. The Xerces feature
http://apache.org/xml/features/validation/schema/element-default allows you to choose whether the
parser reports the default value. The default setting for this feature is to report default values. Default val-
ues are reported via the characters callback, just like any other character data.
Accessing PSVI
Some applications want to access the Post Schema Validation Infoset (PSVI) in order to obtain type infor-
mation about elements and attributes. The Xerces API for accomplishing this has not yet solidified, but it
exists in an experimental form in the org.apache.xerces.xni.psvi package. If your application isn’t access-
ing the PSVI, then you should set the feature http://apache.org/xml/features/validation/schema
/augment-psvi to false so you don’t have to pay the cost of creating the PSVI augmentations.
Overriding schemaLocation Hints
The XML Schema specification says that the xsi:schemaLocation and xsi:noNamespaceSchemaLocation
attributes are hints to the validation engine and that they may be ignored. There are at least two good
reasons your application might want to ignore these hints. First, you shouldn’t believe a document that
purports to tell your application what schema it should use to validate the document. When you wrote
your application, you had a particular version of an XML Schema in mind. The incoming document is
supposed to conform to that schema. But a number of problems can crop up if you believe the incoming
document when it claims to know what schema to use. The author of the incoming document may have
22
Chapter 1
01 543555 Ch01.qxd 11/5/03 9:40 AM Page 22