Class XPathGenerator
java.lang.Object
org.apache.xmlbeans.impl.xpathgen.XPathGenerator
public class XPathGenerator extends Object
Generates an XPath String that points to a given position in an XML document
-
Constructor Summary
Constructors Constructor Description XPathGenerator()
-
Method Summary
Modifier and Type Method Description static String
generateXPath(XmlCursor node, XmlCursor context, NamespaceContext nsctx)
Generates an XPath pointing to the position in the document indicated bynode
.static void
main(String[] args)
-
Constructor Details
-
XPathGenerator
public XPathGenerator()
-
-
Method Details
-
generateXPath
public static String generateXPath(XmlCursor node, XmlCursor context, NamespaceContext nsctx) throws XPathGenerationExceptionGenerates an XPath pointing to the position in the document indicated bynode
.If the
context
parameter is null, the XPath is absolute, otherwise the XPath will be relative to the position indicated bycontext
.Note: the cursor position for the
node
parameter is not preserved- Parameters:
node
- the position in the document that the generated path will point tocontext
- the context node; the generated path will be relative to it if not null and if pointing to an element on the path from the document root tonode
nsctx
- a namespace context that will be used to obtain prefixes; a (non-default) namespace mapping must be available for all required namespace URIs- Returns:
- the generated path as a
String
- Throws:
XPathGenerationException
- if the path could not be generated: the cursor is in a bad position (like over a comment) or no prefix mapping was found for one of the namespace URIs
-
main
- Throws:
XmlException
-