Package gov.nasa.pds.tools.util
Class XMLExtractor
java.lang.Object
gov.nasa.pds.tools.util.XMLExtractor
Class to extract data from an XML file.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionXMLExtractor(File file) XMLExtractor(String url) Constructor.XMLExtractor(URL url) Constructor.XMLExtractor(Source xml) Constructor.XMLExtractor(InputSource source) -
Method Summary
Modifier and TypeMethodDescriptionGets the document node of the XML document.net.sf.saxon.tree.tiny.TinyNodeImplgetNodeFromDoc(String expression) Gets a Node object from the given expression.net.sf.saxon.tree.tiny.TinyNodeImplgetNodeFromItem(String expression, Object item) Gets a Node object from the given expression.List<net.sf.saxon.tree.tiny.TinyNodeImpl>getNodesFromDoc(String expression) Gets Node objects from the given expression.List<net.sf.saxon.tree.tiny.TinyNodeImpl>getNodesFromItem(String expression, Object item) Gets Node objects from the given expression.getValueFromDoc(String expression) Gets the value of the given expression.getValueFromItem(String expression, Object item) Gets the value of the given expression.getValuesFromDoc(String expression) Gets the values of the given expression.getValuesFromItem(String expression, Object item) Gets the values of the given expression.
-
Field Details
-
SCHEMA_LOCATION_XPATH
- See Also:
-
XML_MODEL_XPATH
- See Also:
-
DEFAULT_NAMESPACE
- See Also:
-
TARGET_NAMESPACE
- See Also:
-
-
Constructor Details
-
XMLExtractor
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
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(InputSource source) throws net.sf.saxon.trans.XPathException, XPathExpressionException - Throws:
net.sf.saxon.trans.XPathExceptionXPathExpressionException
-
XMLExtractor
public XMLExtractor(File file) throws net.sf.saxon.trans.XPathException, XPathExpressionException, MalformedURLException - Throws:
net.sf.saxon.trans.XPathExceptionXPathExpressionExceptionMalformedURLException
-
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 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
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
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:
XPathExpressionExceptionnet.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:
XPathExpressionExceptionnet.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:
XPathExpressionExceptionnet.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:
XPathExpressionExceptionnet.sf.saxon.trans.XPathException
-
getSystemId
-