TokenTypes.jws Sample

A web service illustrating how tokens correspond to portions of an XML document. A token represents a logical piece of XML, such  as the start or end of an element, text, a comment, and so on. A token type, on the other hand, represents a kind of token. In other words, a token is a STARTDOC (the very beginning of an XML instance, before all markup),  a START (the start of an element), a COMMENT, and so on.

When navigating XML with a cursor, you move the cursor past tokens using methods such as toNextToken, toNextElement, and so on. It's important to remember that a cursor is almost always immediately before some token. When at a START token, for example, the cursor is just before the start of an element. This also means that it is before the start of an element and after some other token. In other words, calling currentTokenType on an XmlCursor instance will usually return the token that it is immediately before. The exception to this rule is for an ENDDOC token, which is after all other markup. Because it is at the very end, it can't be before anything else.

Concepts Demonstrated by this Sample

Location of Sample Files

This sample is located in the xmlBeans/cursor folder of the SamplesApp WebLogic Workshop project. In the file system the location is:

BEA_HOME\weblogic81\samples\workshop\SamplesApp\WebServices\xmlBeans\cursor\TokenTypes.jws

To Run the Sample

Related Topics

Getting Started with XMLBeans

Navigating XML with Cursors

XmlCursor Interface