Class XMLExtractor

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

public class XMLExtractor
extends Object
Class to extract data from an XML file.
  • Field Details

  • Constructor Details

  • Method Details

    • 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.tree.tiny.TinyNodeImpl getNodeFromDoc​(String expression) throws XPathExpressionException, net.sf.saxon.trans.XPathException
      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.
      net.sf.saxon.trans.XPathException
    • getNodeFromItem

      public net.sf.saxon.tree.tiny.TinyNodeImpl 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, net.sf.saxon.trans.XPathException
      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.
      net.sf.saxon.trans.XPathException
    • 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 Source 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.tree.tiny.TinyNodeImpl> getNodesFromDoc​(String expression) throws XPathExpressionException, net.sf.saxon.trans.XPathException
      Gets Node objects from the given expression.
      Parameters:
      expression - An XPath expression.
      Returns:
      A NodeList object.
      Throws:
      XPathExpressionException - If the given expression was malformed.
      net.sf.saxon.trans.XPathException
    • getNodesFromItem

      public List<net.sf.saxon.tree.tiny.TinyNodeImpl> 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.
    • getSchemaLocation

      public String getSchemaLocation() throws XPathExpressionException, net.sf.saxon.trans.XPathException
      Returns:
      Returns the schemalocation attribute value from the label. If it was not found, a null value will be returned.
      Throws:
      XPathExpressionException
      net.sf.saxon.trans.XPathException
    • getXmlModels

      public List<String> getXmlModels() throws XPathExpressionException, net.sf.saxon.trans.XPathException
      Returns:
      Returns the schematron specifications in the label.
      Throws:
      XPathExpressionException
      net.sf.saxon.trans.XPathException
    • getDefaultNamespace

      public String getDefaultNamespace() throws XPathExpressionException, net.sf.saxon.trans.XPathException
      Returns:
      Returns the 'xmlns' attribute of the document (default namespace)
      Throws:
      XPathExpressionException
      net.sf.saxon.trans.XPathException
    • getTargetNamespace

      public String getTargetNamespace() throws XPathExpressionException, net.sf.saxon.trans.XPathException
      Returns:
      Returns the 'targetNamespace' attribute of the document (default namespace)
      Throws:
      XPathExpressionException
      net.sf.saxon.trans.XPathException
    • getSystemId

      public String getSystemId()