Java Reference
In-Depth Information
<rect width="300" height="100"
style="fill:rgb(0,0,255);stroke-width:1;
stroke:rgb(0,0,0)"/>
</svg>]
endCDATA()
characters() [
]
endElement() uri=[], localName=[example], qName=[example]
ignorableWhitespace() [
]
endElement() uri=[], localName=[svg-examples], qName=[svg-
examples]
endDocument()
This output reveals that the
ignorableWhitespace()
method was called after
startElement()
for
svg-examples
and after
endElement()
for
example
.
Theformertwocallsto
characters()
thatproducedthestrangeoutputwerereport-
ing ignorable whitespace.
RecallthatIpreviouslydefined
ignorable whitespace
aswhitespacelocatedbetween
tagswheretheDTDdoesn'tallowmixedcontent.Forexample,theDTDindicatesthat
svg-examples
shall contain only
example
elements, not
example
elements and
parsedcharacterdata.However,thelineterminatorfollowingthe
<svg-examples>
tagandtheleadingwhitespacebefore
<example>
areparsedcharacterdata.Thepars-
er now reports these characters by calling
ignorableWhitespace()
.
This time, there are only two occurrences of the following output:
characters() [
]
The first occurrence reports the line terminator separately from the
example
ele-
ment'stext(beforetheCDATAsection);itdidnotdosopreviously,whichprovesthat
characters()
is called with either all or part of an element's content. Once again,
the second occurrence reports the line terminator that follows the CDATA section.
Supposeyouwanttovalidate
svg-examples.xml
withoutthepreviouslypresen-
tedinternalDTD.Ifyouattempttodoso(byexecuting
java SAXDemo svg-ex-
amples.xml v
),youwilldiscoveramongitsoutputacoupleoflinesthataresimilar
to those shown here: