background image

Sample Event Mapping

<< XMLEvent Types | Sample Iterator API Event Mapping >>
<< XMLEvent Types | Sample Iterator API Event Mapping >>
I
TERATOR
API
85
Sample Event Mapping
As an example of how the event iterator API maps an XML stream, consider the
following XML document:
<?xml version="1.0"?>
<BookCatalogue xmlns="http://www.publishing.org">
<Book>
<Title>Yogasana Vijnana: the Science of Yoga</Title>
<ISBN>81-40-34319-4</ISBN>
<Cost currency="INR">11.50</Cost>
</Book>
</BookCatalogue>
This document would be parsed into eighteen primary and secondary events, as
shown below. Note that secondary events, shown in curly braces (
{}
), are typi-
cally accessed from a primary event rather than directly.
Table 4­3 Sample Iterator API Event Mapping
#
Element/Attribute
Event
1
version="1.0"
StartDocument
2
isCData = false
data = "\n"
IsWhiteSpace = true
Characters
3
qname = BookCatalogue:http://www.publishing.org
attributes = null
namespaces = {BookCatalogue" -> http://www.publishing.org"}
StartElement
4
qname = Book
attributes = null
namespaces = null
StartElement
5
qname = Title
attributes = null
namespaces = null
StartElement
6
isCData = false
data = "Yogasana Vijnana: the Science of Yoga\n\t"
IsWhiteSpace = false
Characters
7
qname = Title
namespaces = null
EndElement