gov.nasa.pds.tools.util
Class XMLExtractor

java.lang.Object
  extended by gov.nasa.pds.tools.util.XMLExtractor

public class XMLExtractor
extends Object

Class to extract data from an XML file.


Constructor Summary
XMLExtractor(net.sf.saxon.om.DocumentInfo xml)
          Constructor.
XMLExtractor(File file)
           
XMLExtractor(String url)
          Constructor.
XMLExtractor(URL url)
          Constructor.
 
Method Summary
 net.sf.saxon.om.DocumentInfo getDocNode()
          Gets the document node of the XML document.
 net.sf.saxon.tinytree.TinyElementImpl getNodeFromDoc(String expression)
          Gets a Node object from the given expression.
 net.sf.saxon.tinytree.TinyElementImpl getNodeFromItem(String expression, Object item)
          Gets a Node object from the given expression.
 List<net.sf.saxon.tinytree.TinyElementImpl> getNodesFromDoc(String expression)
          Gets Node objects from the given expression.
 List<net.sf.saxon.tinytree.TinyElementImpl> getNodesFromItem(String expression, Object item)
          Gets Node objects from the given expression.
 String getValueFromDoc(String expression)
          Gets the value of the given expression.
 String getValueFromItem(String expression, Object item)
          Gets the value of the given expression.
 List<String> getValuesFromDoc(String expression)
          Gets the values of the given expression.
 List<String> getValuesFromItem(String expression, Object item)
          Gets the values of the given expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLExtractor

public XMLExtractor(net.sf.saxon.om.DocumentInfo xml)
             throws XPathExpressionException,
                    net.sf.saxon.trans.XPathException
Constructor.

Parameters:
xml - A parsed XML document.
Throws:
net.sf.saxon.trans.XPathException - If an error occurred while parsing the given xml file.
XPathExpressionException - If an error occurred while setting up the default namespace.

XMLExtractor

public XMLExtractor(URL url)
             throws net.sf.saxon.trans.XPathException,
                    XPathExpressionException
Constructor.

Parameters:
xmlFile - An xml file.
Throws:
net.sf.saxon.trans.XPathException - If an error occurred while parsing the given xml file.
XPathExpressionException - If an error occurred while setting up the default namespace.

XMLExtractor

public XMLExtractor(File file)
             throws net.sf.saxon.trans.XPathException,
                    XPathExpressionException,
                    MalformedURLException
Throws:
net.sf.saxon.trans.XPathException
XPathExpressionException
MalformedURLException

XMLExtractor

public XMLExtractor(String url)
             throws net.sf.saxon.trans.XPathException,
                    XPathExpressionException,
                    MalformedURLException
Constructor.

Parameters:
xmlFile - An xml file.
Throws:
net.sf.saxon.trans.XPathException - If an error occurred while parsing the given xml file.
XPathExpressionException - If an error occurred while setting up the default namespace.
MalformedURLException
Method Detail

getValueFromDoc

public String getValueFromDoc(String expression)
                       throws XPathExpressionException,
                              net.sf.saxon.trans.XPathException
Gets the value of the given expression.

Parameters:
expression - An XPath expression.
Returns:
The resulting value or null if nothing was found.
Throws:
XPathExpressionException - If the given expression was malformed.
net.sf.saxon.trans.XPathException

getValueFromItem

public String getValueFromItem(String expression,
                               Object item)
                        throws XPathExpressionException
Gets the value of the given expression.

Parameters:
expression - An XPath expression.
item - The starting point from which to evaluate the XPath expression.
Returns:
The resulting value or null if nothing was found.
Throws:
XPathExpressionException - If the given expression was malformed.

getNodeFromDoc

public net.sf.saxon.tinytree.TinyElementImpl getNodeFromDoc(String expression)
                                                     throws XPathExpressionException
Gets a Node object from the given expression.

Parameters:
expression - An XPath expression.
Returns:
A Node object.
Throws:
XPathExpressionException - If the given expression was malformed.

getNodeFromItem

public net.sf.saxon.tinytree.TinyElementImpl getNodeFromItem(String expression,
                                                             Object item)
                                                      throws XPathExpressionException
Gets a Node object from the given expression.

Parameters:
expression - An XPath expression.
item - The starting point from which to evaluate the XPath expression.
Returns:
A Node object.
Throws:
XPathExpressionException - If the given expression was malformed.

getValuesFromDoc

public List<String> getValuesFromDoc(String expression)
                              throws XPathExpressionException
Gets the values of the given expression.

Parameters:
expression - An XPath expression.
Returns:
The resulting values or an empty list if nothing was found.
Throws:
XPathExpressionException - If the given expression was malformed.

getValuesFromItem

public List<String> getValuesFromItem(String expression,
                                      Object item)
                               throws XPathExpressionException
Gets the values of the given expression.

Parameters:
expression - An XPath expression.
item - The starting point from which to evaluate the XPath expression.
Returns:
The resulting values or an empty list if nothing was found.
Throws:
XPathExpressionException - If the given expression was malformed.

getDocNode

public net.sf.saxon.om.DocumentInfo getDocNode()
                                        throws net.sf.saxon.trans.XPathException
Gets the document node of the XML document.

Returns:
The Document Node.
Throws:
net.sf.saxon.trans.XPathException

getNodesFromDoc

public List<net.sf.saxon.tinytree.TinyElementImpl> getNodesFromDoc(String expression)
                                                            throws XPathExpressionException
Gets Node objects from the given expression.

Parameters:
expression - An XPath expression.
Returns:
A NodeList object.
Throws:
XPathExpressionException - If the given expression was malformed.

getNodesFromItem

public List<net.sf.saxon.tinytree.TinyElementImpl> getNodesFromItem(String expression,
                                                                    Object item)
                                                             throws XPathExpressionException
Gets Node objects from the given expression.

Parameters:
expression - An XPath expression.
item - The starting point from which to evaluate the XPath expression.
Returns:
A NodeList object.
Throws:
XPathExpressionException - If the given expression was malformed.


Copyright © 2010-2013 Planetary Data System. All Rights Reserved.