Package org.mycore.common.xml
Class MCRXPathBuilder
java.lang.Object
org.mycore.common.xml.MCRXPathBuilder
Builds an absolute XPath expression for a given element or attribute within a JDOM XML structure.
- Author:
- Frank Lützenkirchen
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
buildChildPath
(Element element) Builds a local XPath fragment as combined namespace prefix, local element name and position predicatestatic String
buildXPath
(Object object) Builds an absolute XPath expression for a given element or attribute within a JDOM XML structure.static String
buildXPath
(Attribute attribute) Builds an absolute XPath expression for the given attribute within a JDOM XML structure.static String
buildXPath
(Element element) Builds an absolute XPath expression for the given element within a JDOM XML structure.static String
getNamespacePrefix
(Element element) Returns the namespace prefix for this element, followed by a ":", or the empty string if no namespace prefix known.
-
Constructor Details
-
MCRXPathBuilder
public MCRXPathBuilder()
-
-
Method Details
-
buildXPath
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
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
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
Builds a local XPath fragment as combined namespace prefix, local element name and position predicate -
getNamespacePrefix
Returns the namespace prefix for this element, followed by a ":", or the empty string if no namespace prefix known.
-