Java Reference
In-Depth Information
Type : CDATA
Value: 0
End element: local name: color qname: color uri:
Ignorable whitespace: 9 characters.
Start element: local name: position qname: position uri:
Attributes:
Name : x
Type : CDATA
Value: 30
Name : y
Type : CDATA
Value: 40
End element: local name: position qname: position uri:
Ignorable whitespace: 9 characters.
Start element: local name: bounds qname: bounds uri:
Attributes:
Name : x
Type : CDATA
Value: 30
Name : y
Type : CDATA
Value: 40
Name : width
Type : CDATA
Value: 32
Name : height
Type : CDATA
Value: 22
End element: local name: bounds qname: bounds uri:
Ignorable whitespace: 5 characters.
End element: local name: rectangle qname: rectangle uri:
Ignorable whitespace: 1 characters.
End element: local name: sketch qname: sketch uri:
End "xsi" namespace scope.
End document
Of course, you can also try the example specifying the schema location by the second argument on the
command line.
How It Works
The only significant difference from what you had in the previous example that processed a document
with a DTD is the creation of the Schema object to identify the schema to be used. When you supply a
second command-line argument, a File object encapsulating the schema file path is created and a ref-
erence to this is passed as the second argument to the process() method. The process() method uses
the second argument that you pass to it to determine how to create the Schema object that is passed to the
setSchema() method for the SAXParserFactory object:
SchemaFactory sf =
SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
spf.setSchema(schemaFile == null ? sf.newSchema() :
sf.newSchema(schemaFile));
Search WWH ::




Custom Search