Package de.elrebo
Class XPathHelper
java.lang.Object
de.elrebo.XPathHelper
Class XPathHelper simplifies Access to XML documents from Java programs.
It evaluates an XPath expression against an XdmNode.
Copyright 2025 Christoph Oberle
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
Constructor Summary
ConstructorsConstructorDescriptionXPathHelper(net.sf.saxon.s9api.Processor processor, String[][] namespaces, String[][] variables, String xPath) Constructor from processor, filePath, namespaces, variables and xPath -
Method Summary
Modifier and TypeMethodDescriptionvoidload xPath Executable into selectornet.sf.saxon.s9api.XPathSelectorsetContextItem(net.sf.saxon.s9api.XdmNode xdmNode) set the context for the XPath evaluation to an XdmNode containing the XML documentvoidsetDoubleVariable(String name, double value) set a double variablevoidsetIntVariable(String name, int value) set an int variablevoidsetStringVariable(String name, String value) set a String variable
-
Constructor Details
-
XPathHelper
public XPathHelper(net.sf.saxon.s9api.Processor processor, String[][] namespaces, String[][] variables, String xPath) throws net.sf.saxon.s9api.SaxonApiException Constructor from processor, filePath, namespaces, variables and xPath- Parameters:
processor- the Saxon processornamespaces- the mapping of namespace prefixes to namespacesvariables- the list of variables (names and types)xPath- the XPath expression- Throws:
net.sf.saxon.s9api.SaxonApiException- if an error occurs
-
-
Method Details
-
loadXPath
public void loadXPath()load xPath Executable into selector -
setIntVariable
set an int variable- Parameters:
name- the name of the variablevalue- the int value for the variable- Throws:
net.sf.saxon.s9api.SaxonApiException- if the variable can't be set
-
setDoubleVariable
public void setDoubleVariable(String name, double value) throws net.sf.saxon.s9api.SaxonApiException set a double variable- Parameters:
name- the name of the variablevalue- the double value for the variable- Throws:
net.sf.saxon.s9api.SaxonApiException- if the variable can't be set
-
setStringVariable
public void setStringVariable(String name, String value) throws net.sf.saxon.s9api.SaxonApiException set a String variable- Parameters:
name- the name of the variablevalue- the String value for the variable- Throws:
net.sf.saxon.s9api.SaxonApiException- if the variable can't be set
-
setContextItem
public net.sf.saxon.s9api.XPathSelector setContextItem(net.sf.saxon.s9api.XdmNode xdmNode) throws net.sf.saxon.s9api.SaxonApiException set the context for the XPath evaluation to an XdmNode containing the XML document- Parameters:
xdmNode- the XdmNode containing the XML document- Returns:
- XPathSelector the selector for the XPath evaluation results
- Throws:
net.sf.saxon.s9api.SaxonApiException- if an error occurs
-