Package de.elrebo

Class XPathHelper

java.lang.Object
de.elrebo.XPathHelper

public class XPathHelper extends Object
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 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 processor
      namespaces - the mapping of namespace prefixes to namespaces
      variables - 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

      public void setIntVariable(String name, int value) throws net.sf.saxon.s9api.SaxonApiException
      set an int variable
      Parameters:
      name - the name of the variable
      value - 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 variable
      value - 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 variable
      value - 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