The Parser Xbean


The parser is a source Xbean that converts an XML document in its textual form into a DOM document. The parser Xbean implementation uses any JAXP standard parser to accomplish the parsing. 

Bean Properties

XMLSource A convenience property when the XML input is in a text file. This property gives the name of the XML file to be parsed. Note that setting this property overrides setting the XMLInputStream property. If XMLSource is set, the XMLInputStream property will be ignored. 
XMLInputStream A that is to be parsed. See XMLSource property above about precidence of XMLSource and XMLInputStream.
DOMListener As with all source Xbeans, the DOMListener property is the next Xbean in the channel. The DOMListener receives the DOM produced by this Xbean.


The parser Xbean is in the org.xbeans.parser package. The package can be imported into Java source code as follows:

import org.xbeans.parser.ParserBean;

Creating a parser Xbean is accomplished by instantiating the class:

ParserBean parser = new ParserBean();

Note that if you are using a Java Bean design tools found in many Java Integrated Development Environments, the above code is generated automatically when you drag and drop a parser Xbean into your application.

After creating the parser Xbean, you must set either the XMLSource or XMLInputStream property. For example:


You need to establish which Xbean will receive the DOM document from the parser. To pass the document on to the next Xbean, you simply register the next Xbean to be the DOM Listener.


Again, if you are using a Java Bean design tool, the above calls to set properties may be automatically generated for you.

Finally, to cause the document to be parsed and the DOM produced to be passed to the DOMListener, you must invoke the generateDocument() call:


Source files