Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


com.tangosol.run.xml
Class SaxParser

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.run.xml.SaxParser


public class SaxParser
extends Base

A simple XML parser. The public interface consists of nearly identical methods: parseXml(...) which produce a tree of SimpleElement objects

Author:
gg 2000.10.23

Nested Class Summary
protected  class SaxParser.ValidationHandler
          An inner class Error Handler that is registered in parser that performs validation.

 

Constructor Summary
SaxParser()
          Construct a SaxParser.
SaxParser(boolean fAllowComments)
          Construct a SaxParser.

 

Method Summary
protected static org.xml.sax.Parser getParser()
          Get an instance of non-validating SAX parser.
protected  XmlElement instantiateRoot(java.lang.String sRoot)
          Instantiate an XmlElement implementation for a root element.
static void main(java.lang.String[] asParam)
          Unit test: create a simple parser, parse and output the result.
 XmlElement parseXml(org.xml.sax.InputSource input)
          Parse the specified InputSource into a tree of XmlElement objects ignoring any XML nodes other then elements, text or comments (in a case of SaxParser that allows comments).
protected  XmlElement parseXml(org.xml.sax.InputSource input, XmlElement xmlRoot)
           
 XmlElement parseXml(java.io.InputStream input)
          Parse the specified InputStream into a tree of XmlElement objects ignoring any XML nodes other then elements, text or comments (in a case of SaxParser that allows comments).
 XmlElement parseXml(java.io.Reader input)
          Parse the specified Reader into a tree of XmlElement objects ignoring any XML nodes other then elements, text or comments (in a case of SaxParser that allows comments).
 XmlElement parseXml(java.lang.String sXml)
          Parse the specified String into a tree of XmlElement objects ignoring any XML nodes other then elements, text or comments (in a case of SaxParser that allows comments).
 XmlElement parseXml(java.lang.String sXml, XmlElement elRoot)
          Parse the specified String into a tree of XmlElement objects (same as above) having the specified [empty] XmlElement a root.
protected  javax.xml.transform.Source[] resolveSchemaSources(java.util.List listUri)
          For a given set of XSD URIs, return the Sources to be used by the XML parser to validate an XML document.
 void validateXsd(java.lang.String sXml, XmlDocument xml)
          XSD aware parsing routine; if XML contains an XSD reference to a schemeLocation/noNamespaceSchemaLocation then parse XML using provided XSD for validation.

 

Constructor Detail

SaxParser

public SaxParser()
Construct a SaxParser.

SaxParser

public SaxParser(boolean fAllowComments)
Construct a SaxParser.
Parameters:
fAllowComments - if true, the resulting tree may contain the XMLValue nodes that contain comments; otherwize all comments are ignored

Method Detail

main

public static void main(java.lang.String[] asParam)
Unit test: create a simple parser, parse and output the result.

parseXml

public XmlElement parseXml(java.lang.String sXml)
                    throws org.xml.sax.SAXException
Parse the specified String into a tree of XmlElement objects ignoring any XML nodes other then elements, text or comments (in a case of SaxParser that allows comments). In addition, the text value is trimmed for all nodes except leafs.
Throws:
org.xml.sax.SAXException

parseXml

public XmlElement parseXml(java.lang.String sXml,
                           XmlElement elRoot)
                    throws org.xml.sax.SAXException
Parse the specified String into a tree of XmlElement objects (same as above) having the specified [empty] XmlElement a root. Note: this method is used by de-serialization (see SimpleElement#readExternal)
Throws:
org.xml.sax.SAXException

parseXml

public XmlElement parseXml(java.io.InputStream input)
                    throws org.xml.sax.SAXException
Parse the specified InputStream into a tree of XmlElement objects ignoring any XML nodes other then elements, text or comments (in a case of SaxParser that allows comments). In addition, the text value is trimmed for all nodes except leafs.
Throws:
org.xml.sax.SAXException

parseXml

public XmlElement parseXml(java.io.Reader input)
                    throws org.xml.sax.SAXException
Parse the specified Reader into a tree of XmlElement objects ignoring any XML nodes other then elements, text or comments (in a case of SaxParser that allows comments). In addition, the text value is trimmed for all nodes except leafs.
Throws:
org.xml.sax.SAXException

parseXml

public XmlElement parseXml(org.xml.sax.InputSource input)
                    throws org.xml.sax.SAXException
Parse the specified InputSource into a tree of XmlElement objects ignoring any XML nodes other then elements, text or comments (in a case of SaxParser that allows comments). In addition, the text value is trimmed for all nodes except leafs.
Throws:
org.xml.sax.SAXException

parseXml

protected XmlElement parseXml(org.xml.sax.InputSource input,
                              XmlElement xmlRoot)
                       throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

validateXsd

public void validateXsd(java.lang.String sXml,
                        XmlDocument xml)
                 throws org.xml.sax.SAXException,
                        java.io.IOException,
                        javax.xml.parsers.ParserConfigurationException
XSD aware parsing routine; if XML contains an XSD reference to a schemeLocation/noNamespaceSchemaLocation then parse XML using provided XSD for validation.
Parameters:
sXml - the XML to parse (as a string)
xml - the XML document object used to obtain schema locations
Throws:
org.xml.sax.SAXException - if XML contains an XSD reference and does not pass validation
java.io.IOException - if XML contains a schema that cannot be loaded
javax.xml.parsers.ParserConfigurationException - if a parser cannot be created

resolveSchemaSources

protected javax.xml.transform.Source[] resolveSchemaSources(java.util.List listUri)
                                                     throws java.io.IOException
For a given set of XSD URIs, return the Sources to be used by the XML parser to validate an XML document.
Parameters:
listUri - list of XSD URIs to convert
Returns:
an array of Sources to be used by the XML parser
Throws:
java.io.IOException - if the resource cannot be located or loaded

instantiateRoot

protected XmlElement instantiateRoot(java.lang.String sRoot)
Instantiate an XmlElement implementation for a root element.
Parameters:
sRoot - root name
Returns:
a new XmlElement to be used as the root element

getParser

protected static org.xml.sax.Parser getParser()
                                       throws java.lang.Exception
Get an instance of non-validating SAX parser.
Throws:
java.lang.Exception

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.