|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tribble.xml.impl.XmlReader
XML document reader.
XML documents are read in a "pull" fashion, where each item (tagged element, attribute, text content, and comment) is read individually by request. This is in contrast to other parser designs, such as SAX, which reads XML text and calls registered "callback" methods as each item is parsed, and DOM, which reads XML documents in their entirety.
This particular implementation relaxes some of the constraints of normal XML text:
Note that these enhancements allow nonconforming XML text to be accepted as valid XML.
Example
Consider the following XML document:
<?xml version='1.0'?> <!-- Generated: 2003-05-13 21:52 Z --> <purchase-order form="A001"> <customer> <address>2500 Main Street, Dallas, TX 75025</address> <Shipping-Code CODE = "4B"/> <!-- Query: SKU="HG-52814(J)-F" --> <item Count="20" SKU="HG-52814(J)-F" Unit-Cost="149.95"> Oak business desk, <![CDATA[cherry & chrome]]> finish </item> </customer> <!-- Tax rate: NJ --> </purchase-order>
The XML document above is read as the following sequence of XML items:
directive "xml" attribute "version", "1.0" comment " Generated: 2003-05-13 21:52 Z " element "purchase-order" attribute "form", "A001" element "customer" element "address" text "2500 Main Street, Dallas, TX 75025" element "Shipping-Code" attribute "code", "4B" comment " Query: SKU=\"HG-52814(J)-F\" " element "item" attribute "Count", "20" attribute "SKU", "HG-52814(J)-F" attribute "Unit-Cost", "149.95" text "Oak business desk, cherry & chrome finish" comment " Tax rate: NJ "
XmlWriter
Field Summary |
Fields inherited from interface tribble.xml.XmlReaderI |
FLAG_COMBINE_TEXT, FLAG_KEEP_COMMENTS, FLAG_KEEP_SPACES |
Constructor Summary | |
XmlReader(java.io.InputStream in)
Constructor. |
|
XmlReader(java.io.Reader in)
Constructor. |
Method Summary | |
void |
close()
Close this XML input stream. |
XmlItemI |
readItem()
Read the next XML item from this XML input stream. |
boolean |
setControlFlag(java.lang.String flag,
boolean val)
Modify a control flag of this XML input stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XmlReader(java.io.Reader in)
in
- A character input stream from which to read XML documents.public XmlReader(java.io.InputStream in)
in
- A byte input stream from which to read XML documents.
The input stream is assumed to be UTF-8 encoded characters.Method Detail |
public void close() throws java.io.IOException
Note that the parser is no longer usable after this method has been called.
close
in interface XmlReaderI
java.io.IOException
- Thrown if an I/O error occurs.public boolean setControlFlag(java.lang.String flag, boolean val)
setControlFlag
in interface XmlReaderI
flag
- The name of a control flag to modify.val
- The value to change the control flag to.
java.lang.IllegalArgumentException
- (unchecked)
Thrown if flag does not name a supported control flag.public XmlItemI readItem() throws java.io.IOException
readItem
in interface XmlReaderI
java.io.IOException
- Thrown if an I/O (read) error occurs.
java.lang.IllegalStateException
- (unchecked)
Thrown if this reader is not in the proper state for reading an XML item
(e.g., after the end of the XML input stream has been reached).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |