ptolemy.data.expr
Class XMLParser

java.lang.Object
  extended by ptolemy.data.expr.XMLParser

public class XMLParser
extends java.lang.Object

This class parses a XML string token to a DOM document.

Since:
Ptolemy II 4.0
Version:
$Id: XMLParser.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Yang Zhao
Accepted Rating:
Yellow (yuhong)
Proposed Rating:
Yellow (nsmyth)

Nested Class Summary
static class XMLParser.EntityResolver
          The entity resolver that tries to first load a DTD file locally, and if it is not found, looks for it on the Internet using the DTD file's system ID.
 
Field Summary
private  javax.xml.parsers.DocumentBuilder _documentBuilder
           
private  javax.xml.parsers.DocumentBuilderFactory _documentBuilderFactory
           
 
Constructor Summary
XMLParser()
           
 
Method Summary
 org.w3c.dom.Document parser(java.io.InputStream is)
          Generate the document tree for the specified input stream.
 org.w3c.dom.Document parser(java.lang.String str)
          Generate the document tree for the specified XML string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_documentBuilderFactory

private javax.xml.parsers.DocumentBuilderFactory _documentBuilderFactory

_documentBuilder

private javax.xml.parsers.DocumentBuilder _documentBuilder
Constructor Detail

XMLParser

public XMLParser()
          throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

parser

public org.w3c.dom.Document parser(java.lang.String str)
                            throws java.lang.Exception
Generate the document tree for the specified XML string. The Document (the root of the document tree) is returned. An exception will be thrown if the parse fails.

Parameters:
str - The XML string to be parsed.
Returns:
The document for the parse tree.
Throws:
java.lang.Exception - If the parse fails.

parser

public org.w3c.dom.Document parser(java.io.InputStream is)
                            throws java.lang.Exception
Generate the document tree for the specified input stream. The Document (the root of the document tree) is returned. An exception will be thrown if the parse fails.

Parameters:
is - The input steam to be parsed.
Returns:
The document for the parse tree.
Throws:
java.lang.Exception - If the parse fails.