Running cursor2event Sample
108
S
TREAMING
API
FOR
XML
return "START_DOCUMENT";
case XMLEvent.END_DOCUMENT:
return "END_DOCUMENT";
case XMLEvent.ENTITY_REFERENCE:
return "ENTITY_REFERENCE";
case XMLEvent.ATTRIBUTE:
return "ATTRIBUTE";
case XMLEvent.DTD:
return "DTD";
case XMLEvent.CDATA:
return "CDATA";
case XMLEvent.SPACE:
return "SPACE";
}
return "UNKNOWN_EVENT_TYPE " + "," + eventType;
}
Running the Sample
When you run the
EventParse
sample, the class is compiled, and the XML
stream is parsed as events and returned to
STDOUT
. For example, an instance of
the
Author
element is returned as:
<['http://www.publishing.org']::Author>
Dhirendra Brahmachari
</['http://www.publishing.org']::Author>
Note in this example that the event comprises an opening and closing tag, both of
which include the namespace. The content of the element is returned as a string
within the tags.
Similarly, an instance of the
Cost
element is returned as:
<['http://www.publishing.org']::Cost currency='INR'>
11.50
</['http://www.publishing.org']::Cost>
In this case, the
currency
attribute and value are returned in the opening tag for
the event.