Java Reference
In-Depth Information
output
title = Beginning Groovy and Grails, isbn =
9781430210450
,whereas
java SAXSearch "addison wesley"
should output
title = Advanced C++, isbn = 0201548550
followedby
title = Effective Java, isbn = 0201310058
on
separate lines. Nothing should output if the command-line publisher name
argument does not match a
publisher
element's text.
4. Create a
DOMSearch
application that is the equivalent of Exercise 3's
SAXSearch
application.
5. Createa
ParseXMLDoc
applicationthatusesaStAXstream-basedreader
toparseitssinglecommand-lineargument,anXMLdocument.Aftercreat-
ingthisreader,theapplicationshouldverifythata
START_DOCUMENT
in-
fosetitemhasbeendetected,andthenenteraloopthatreadsthenextitem
and uses a switch statement to output a message corresponding to the item
thathasbeenread:
ATTRIBUTE
,
CDATA
,
CHARACTERS
,
COMMENT
,
DTD
,
END_ELEMENT
,
ENTITY_DECLARATION
,
ENTITY_REFERENCE
,
NAMESPACE
,
NOTATION_DECLARATION
,
PROCESSING_INSTRUCTION
,
SPACE
, or
START_ELEMENT
. When
START_ELEMENT
isdetected,outputthiselement'snameandlocalname,
andoutputthelocalnamesandvaluesofallattributes.Theloopendswhen
the
END_DOCUMENT
infoset item has been detected. Explicitly close the
stream reader followed by the file reader upon which it is based. Test this
application with Exercise 1's
books.xml
file.
6. Modify
Listing 10-20
'
s contacts document by changing
<name>John
Doe</name>
to
<Name>John Doe</Name>
. Because you no longer
application(youonlysee
Bob Jones
),modifythisapplication'slocation
path expression so that you see
John Doe
followed by
Bob Jones
.
7. Create a
books.xsl
stylesheet file, and a
MakeHTML
application with
a similar structure to the application that processes
Listing 10-28
'
s
re-
cipe.xsl
stylesheet.
MakeHTML
uses
books.xsl
to convert Exercise
1's
books.xml
content to HTML. When viewed in a web browser, the
HTMLshouldresultinawebpagethat'ssimilartothepageshownin
Figure