Java Reference
In-Depth Information
You need to copy the MySAXHandler.java source file from the previous example to the folder you are
using for this example. You have the option of supplying an additional command-line argument when
you run the program. The first argument is the name of the XML file to be parsed, as in the TrySAXHand-
ler example; the second argument is the path to the schema that is to be used to parse the file. When
the second argument is present, the program processes the XML file using the specified schema. If the
second argument is absent, the XML file is processed using the schema specified by hints in the docu-
ment.
Processing the sketch1.xml file that I defined in the previous section resulted in the following output:
Starting parsing of D:\Beg Java Stuff\sketch1.xml
Start document:
Start "xsi" namespace scope. URI: http://www.w3.org/2001/
XMLSchema-instance
Start element: local name: sketch qname: sketch uri:
Attributes:
Name : xsi:noNamespaceSchemaLocation
Type : CDATA
Value: file:/D:/Beg%20Java%20Stuff/Sketcher.xsd
Ignorable whitespace: 5 characters.
Start element: local name: circle qname: circle uri:
Attributes:
Name : diameter
Type : CDATA
Value: 40
Name : angle
Type : CDATA
Value: 0.0
Ignorable whitespace: 9 characters.
This is followed by a lot more output that ends:
Start element: local name: rectangle qname: rectangle uri:
Attributes:
Name : width
Type : CDATA
Value: 30.0
Name : height
Type : CDATA
Value: 20.0
Name : angle
Type : CDATA
Value: 0.0
Ignorable whitespace: 9 characters.
Start element: local name: color qname: color uri:
Attributes:
Name : R
Type : CDATA
Value: 255
Name : G
Type : CDATA
Value: 0
Name : B
Search WWH ::




Custom Search