background image

Returning the Output

<< Creating an Input Factory | Building and Running the Event Example >>
<< Creating an Input Factory | Building and Running the Event Example >>

Returning the Output

case XMLEvent.END_ELEMENT:
return
"END_ELEMENT";
case XMLEvent.PROCESSING_INSTRUCTION:
return
"PROCESSING_INSTRUCTION";
case XMLEvent.CHARACTERS:
return
"CHARACTERS";
case XMLEvent.COMMENT:
return
"COMMENT";
case XMLEvent.START_DOCUMENT:
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;
}
Returning the Output
When you run the Event example, the EventParse 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.
Example Code
The Java EE 5 Tutorial · September 2007
574