Class MCRXPathBuilder

java.lang.Object
org.mycore.common.xml.MCRXPathBuilder

public class MCRXPathBuilder extends Object
Builds an absolute XPath expression for a given element or attribute within a JDOM XML structure.
Author:
Frank Lützenkirchen
  • Constructor Details

    • MCRXPathBuilder

      public MCRXPathBuilder()
  • Method Details

    • buildXPath

      public static String buildXPath(Object object)
      Builds an absolute XPath expression for a given element or attribute within a JDOM XML structure. For each element that is not the root element, the XPath will also contain a position predicate. For all namespaces commonly used in MyCoRe, their namespace prefixes will be used.
      Parameters:
      object - a JDOM element or attribute
      Returns:
      absolute XPath of that object. In case there is a root Document, it will begin with a "/".
    • buildXPath

      public static String buildXPath(Attribute attribute)
      Builds an absolute XPath expression for the given attribute within a JDOM XML structure. For each element that is not the root element, the XPath will also contain a position predicate. For all namespaces commonly used in MyCoRe, their namespace prefixes will be used.
      Parameters:
      attribute - a JDOM attribute
      Returns:
      absolute XPath of that attribute. In case there is a root Document, it will begin with a "/".
    • buildXPath

      public static String buildXPath(Element element)
      Builds an absolute XPath expression for the given element within a JDOM XML structure. For each element that is not the root element, the XPath will also contain a position predicate. For all namespaces commonly used in MyCoRe, their namespace prefixes will be used.
      Parameters:
      element - a JDOM element
      Returns:
      absolute XPath of that element. In case there is a root Document, it will begin with a "/".
    • buildChildPath

      public static String buildChildPath(Element element)
      Builds a local XPath fragment as combined namespace prefix, local element name and position predicate
    • getNamespacePrefix

      public static String getNamespacePrefix(Element element)
      Returns the namespace prefix for this element, followed by a ":", or the empty string if no namespace prefix known.