Package gov.nasa.pds.harvest.search.util
Class XMLExtractor
- java.lang.Object
- 
- gov.nasa.pds.harvest.search.util.XMLExtractor
 
- 
 public class XMLExtractor extends Object Class to extract data from an XML file.
- 
- 
Constructor SummaryConstructors Constructor Description XMLExtractor()Constructor.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>getAttributeValuesFromDoc(String expression)Gets the values of the given expression.List<String>getAttributeValuesFromItem(String expression, Object item)Gets the values of the given expression.static StringgetDefaultNamespace()Get the default namespace URI.net.sf.saxon.om.DocumentInfogetDocNode()Gets the document node of the XML document.net.sf.saxon.tree.tiny.TinyElementImplgetNodeFromDoc(String expression)Gets a Node object from the given expression.net.sf.saxon.tree.tiny.TinyElementImplgetNodeFromItem(String expression, Object item)Gets a Node object from the given expression.List<net.sf.saxon.tree.tiny.TinyElementImpl>getNodesFromDoc(String expression)Gets Node objects from the given expression.List<net.sf.saxon.tree.tiny.TinyElementImpl>getNodesFromItem(String expression, Object item)Gets Node objects from the given expression.StringgetValueFromDoc(String expression)Gets the value of the given expression.StringgetValueFromItem(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.voidparse(File src)Parse the given file.voidparse(String src)Parse the given file.static voidsetDefaultNamespace(String uri)Sets the default namespace URI.static voidsetNamespaceContext(PDSNamespaceContext context)Sets the Namespace Context to support handling of namespaces in XML documents.
 
- 
- 
- 
Method Detail- 
parsepublic void parse(File src) throws net.sf.saxon.trans.XPathException Parse the given file.- Parameters:
- src- An XML file.
- Throws:
- net.sf.saxon.trans.XPathException- If an error occurred while parsing the XML file.
 
 - 
parsepublic void parse(String src) throws net.sf.saxon.trans.XPathException Parse the given file.- Parameters:
- src- An XML file.
- Throws:
- net.sf.saxon.trans.XPathException- If an error occurred while parsing the XML file.
 
 - 
setDefaultNamespacepublic static void setDefaultNamespace(String uri) Sets the default namespace URI.- Parameters:
- uri- A URI.
 
 - 
getDefaultNamespacepublic static String getDefaultNamespace() Get the default namespace URI.- Returns:
- The namespace.
 
 - 
setNamespaceContextpublic static void setNamespaceContext(PDSNamespaceContext context) Sets the Namespace Context to support handling of namespaces in XML documents.- Parameters:
- context- The NamespaceContext object.
 
 - 
getValueFromDocpublic 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
 
 - 
getValueFromItempublic 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.
 
 - 
getNodeFromDocpublic net.sf.saxon.tree.tiny.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.
 
 - 
getNodeFromItempublic net.sf.saxon.tree.tiny.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.
 
 - 
getValuesFromDocpublic 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.
 
 - 
getValuesFromItempublic 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.
 
 - 
getDocNodepublic net.sf.saxon.om.DocumentInfo getDocNode() throws net.sf.saxon.trans.XPathExceptionGets the document node of the XML document.- Returns:
- The Document Node.
- Throws:
- net.sf.saxon.trans.XPathException
 
 - 
getNodesFromDocpublic List<net.sf.saxon.tree.tiny.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.
 
 - 
getNodesFromItempublic List<net.sf.saxon.tree.tiny.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.
 
 - 
getAttributeValuesFromDocpublic List<String> getAttributeValuesFromDoc(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.
 
 - 
getAttributeValuesFromItempublic List<String> getAttributeValuesFromItem(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.
 
 
- 
 
-