<s>
Streaming	B-Language
API	I-Language
for	I-Language
XML	I-Language
(	O
StAX	B-Language
)	O
is	O
an	O
application	O
programming	O
interface	O
(	O
API	B-General_Concept
)	O
to	O
read	O
and	O
write	O
XML	B-Protocol
documents	I-Protocol
,	O
originating	O
from	O
the	O
Java	B-Language
programming	I-Language
language	I-Language
community	O
.	O
</s>
<s>
Traditionally	O
,	O
XML	B-Protocol
APIs	B-General_Concept
are	O
either	O
:	O
</s>
<s>
Both	O
have	O
advantages	O
:	O
DOM	B-General_Concept
,	O
for	O
example	O
,	O
allows	O
for	O
random	O
access	O
to	O
the	O
document	O
,	O
and	O
event	O
driven	O
algorithm	O
like	O
SAX	B-Application
has	O
a	O
small	O
memory	O
footprint	O
and	O
is	O
typically	O
much	O
faster	O
.	O
</s>
<s>
A	O
tree	O
based	O
API	B-General_Concept
allows	O
unlimited	O
,	O
random	O
access	O
and	O
manipulation	O
,	O
while	O
an	O
event	O
based	O
API	B-General_Concept
is	O
a	O
'	O
one	O
shot	O
 '	O
pass	O
through	O
the	O
source	O
document	O
.	O
</s>
<s>
StAX	B-Language
was	O
designed	O
as	O
a	O
median	O
between	O
these	O
two	O
opposites	O
.	O
</s>
<s>
In	O
the	O
StAX	B-Language
metaphor	O
,	O
the	O
programmatic	O
entry	O
point	O
is	O
a	O
cursor	O
that	O
represents	O
a	O
point	O
within	O
the	O
document	O
.	O
</s>
<s>
This	O
is	O
different	O
from	O
an	O
event	O
based	O
API	B-General_Concept
-	O
such	O
as	O
SAX	B-Application
-	O
which	O
'	O
pushes	O
 '	O
data	O
to	O
the	O
application	O
-	O
requiring	O
the	O
application	O
to	O
maintain	O
state	O
between	O
events	O
as	O
necessary	O
to	O
keep	O
track	O
of	O
location	O
within	O
the	O
document	O
.	O
</s>
<s>
StAX	B-Language
has	O
its	O
roots	O
in	O
a	O
number	O
of	O
incompatible	O
pull	O
APIs	B-General_Concept
for	O
XML	B-Protocol
,	O
most	O
notably	O
,	O
the	O
authors	O
of	O
which	O
(	O
Stefan	O
Haustein	O
and	O
Aleksander	O
Slominski	O
)	O
collaborated	O
with	O
,	O
amongst	O
others	O
,	O
BEA	O
Systems	O
,	O
Oracle	B-Application
,	O
Sun	O
and	O
James	O
Clark	O
.	O
</s>
<s>
The	O
following	O
Java	B-Language
API	B-General_Concept
shows	O
the	O
main	O
methods	O
for	O
reading	O
XML	B-Protocol
in	O
the	O
cursor	O
approach	O
.	O
</s>
<s>
The	O
writing	O
side	O
of	O
the	O
API	B-General_Concept
has	O
methods	O
that	O
correspond	O
to	O
the	O
reading	O
side	O
for	O
“	O
StartElement	O
”	O
and	O
“	O
EndElement	O
”	O
event	O
types	O
.	O
</s>
<s>
This	O
example	O
illustrates	O
how	O
to	O
instantiate	O
an	O
input	O
factory	O
,	O
create	O
a	O
reader	O
and	O
iterate	O
over	O
the	O
elements	O
of	O
an	O
XML	B-Protocol
document	I-Protocol
.	O
</s>
