public class XPointerReferenceResolver extends java.lang.Object implements InternalReferenceResolverInterface
This is a resolver for internal references which can evaluate a limited set of XPointers, according to XML Pointer Framework. The following subset of XPointers can be evaluated by this implementation:
element scheme (see XPointer element() Scheme.
xmlns and xpointer schemes (see
XPointer xpointer() Scheme), if all
parts in the xpointer scheme have expressions according to XPath 1.0.
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
ELEMENT_OPENER_
Opener for an XPointer part in the element scheme.
|
protected org.w3c.dom.NodeList |
hereResult_
Contains the result for the here() function, which could be used in the XPointer.
|
protected InternalReferenceResolverImpl |
subsidiary_
Reference resolver used for internal URIs which are not XPointers.
|
protected org.w3c.dom.Document |
xmlDocumentOM_
The XML document for which the internal URI should be resolved.
|
protected static java.lang.String |
XMLNS_OPENER_
Opener for an XPointer part in the xmlns scheme.
|
protected static java.lang.String |
XPOINTER_OPENER_
Opener for an XPointer part in the xpointer scheme.
|
| Constructor and Description |
|---|
XPointerReferenceResolver()
Standard constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected static java.lang.String |
convertElementPart(java.lang.String element)
Converts an element XPointer part into an xpointer XPointer part.
|
protected static java.lang.String |
convertElementParts(java.lang.String fullXPointer)
Converts all element scheme parts of a full XPointer into xpointer scheme parts.
|
protected static java.lang.String |
convertShorthandXPointer(java.lang.String shorthand)
Converts a shorthand XPointer into a full XPointer.
|
protected org.w3c.dom.NodeList |
evaluateXPointer(java.lang.String xpointerString)
Evaluates the URI reference XPointer.
|
protected static int |
findClosingBrace(java.lang.String candidate,
int startPos)
Finds the position of the closing brace (
() in the candidate string, starting at the
specified start position. |
protected java.lang.String |
makePrefixString(java.util.Hashtable namespaces)
Produces a space separated list of the namespace prefixes.
|
protected static java.util.Hashtable |
parseXmlNSDeclarations(java.lang.String xpointerString)
Evaluates the XPointer parts in the
xmlns scheme, according to XPointer xmlns() Scheme. |
protected static java.util.Vector |
parseXPointers(java.lang.String xpointerString)
Collects the XPointer parts in the
xpointer scheme. |
org.w3c.dom.NodeList |
resolve(URI uri,
org.w3c.dom.Document xmlDocumentOM,
org.w3c.dom.NodeList hereResult)
Gets a list of DOM nodes representing a flat view on the parts of an XML document selected by the given
internal URI.
|
protected org.w3c.dom.NodeList |
resolve(URI uri,
org.w3c.dom.Document xmlDocumentOM,
org.w3c.dom.NodeList hereResult,
int resultType)
Gets a list of DOM nodes representing a flat view on the parts of an XML document selected by the given
internal URI.
|
org.w3c.dom.NodeList |
resolveForest(URI uri,
org.w3c.dom.Document xmlDocumentOM,
org.w3c.dom.NodeList hereResult)
Gets a list of DOM nodes representing a forest view on the parts of an XML document selected by the
given internal URI.
|
protected static final java.lang.String XMLNS_OPENER_
protected static final java.lang.String XPOINTER_OPENER_
protected static final java.lang.String ELEMENT_OPENER_
protected InternalReferenceResolverImpl subsidiary_
protected org.w3c.dom.Document xmlDocumentOM_
protected org.w3c.dom.NodeList hereResult_
public XPointerReferenceResolver()
public org.w3c.dom.NodeList resolve(URI uri, org.w3c.dom.Document xmlDocumentOM, org.w3c.dom.NodeList hereResult) throws InternalReferenceResolverException
resolve in interface InternalReferenceResolverInterfaceuri - Specifies the internal reference. Must not be null and must either be empty
("") or reference-only (starting with #). Please see the
class description for supported reference-only URIs.xmlDocumentOM - The object model for the XML document to be processed. Must not be null
.hereResult - A org.w3c.dom.NodeList>/code> containing a single DOM node. This single DOM
node should be the node containing the URI reference, according to XPointer, section 5.4.4.
May be null, if the URI reference is not an XPointer, or if no call
here() appears in the XPointer.InternalReferenceResolverException - if providing the list of DOM nodes fails for any reason.public org.w3c.dom.NodeList resolveForest(URI uri, org.w3c.dom.Document xmlDocumentOM, org.w3c.dom.NodeList hereResult) throws InternalReferenceResolverException
uri - Specifies the internal reference. Must not be null.xmlDocumentOM - The object model for the XML document to be processed. Must not be null
.hereResult - A org.w3c.dom.NodeList>/code> containing a single DOM node. This single DOM
node should be the node containing the URI reference, according to XPointer, section
4.5.4.
May be null, if the URI reference is not an XPointer, or if no call
here() appears in the XPointer.InternalReferenceResolverException - if providing the list of DOM nodes fails for any reason.protected org.w3c.dom.NodeList resolve(URI uri, org.w3c.dom.Document xmlDocumentOM, org.w3c.dom.NodeList hereResult, int resultType) throws InternalReferenceResolverException
uri - Specifies the internal reference. Must not be null and must either be empty
("") or reference-only (starting with #). Please see the
class description for supported reference-only URIs.xmlDocumentOM - The object model for the XML document to be processed. Must not be null
.hereResult - A org.w3c.dom.NodeList>/code> containing a single DOM node. This single DOM
node should be the node containing the URI reference, according to XPointer, section 5.4.4.
May be null, if the URI reference is not an XPointer, or if no call
here() appears in the XPointer.resultType - Specifies wheter element nodes in the node set resulting from evaluating the XPointer
should be expanded or not. Allowed values are InternalReferenceResolverImpl.FLAT_RESULT_ and InternalReferenceResolverImpl.FOREST_RESULT_InternalReferenceResolverException - if providing the list of DOM nodes fails for any reason.protected org.w3c.dom.NodeList evaluateXPointer(java.lang.String xpointerString)
throws InternalReferenceResolverException
xpointer scheme, the XPointer parts are evaluated from the left to the right. After the
first successful evaluation the processing is stopped.xpointerString - The URI reference XPointer to be evaluated.resolve(iaik.ixsil.util.URI, org.w3c.dom.Document, org.w3c.dom.NodeList).InternalReferenceResolverException - If the evaluation fails for any reason.protected java.lang.String makePrefixString(java.util.Hashtable namespaces)
namespaces - A hash table using namespace declaration attributes as keys.protected static java.util.Hashtable parseXmlNSDeclarations(java.lang.String xpointerString)
throws InternalReferenceResolverException
xmlns scheme, according to XPointer xmlns() Scheme.xpointerString - The XPointer string whose parts in the xmlns scheme should be
evaluated.InternalReferenceResolverException - if the XPointer string cannot be parsed correctly.protected static java.util.Vector parseXPointers(java.lang.String xpointerString)
throws InternalReferenceResolverException
xpointer scheme.xpointerString - The XPointer string whose parts in the xpointer scheme should be
collected.InternalReferenceResolverException - if the XPointer string cannot be parsed correctly.protected static java.lang.String convertShorthandXPointer(java.lang.String shorthand)
shorthand - The shorthand XPointer to be converted.protected static java.lang.String convertElementPart(java.lang.String element)
element - The element XPointer to be converted.protected static java.lang.String convertElementParts(java.lang.String fullXPointer)
throws InternalReferenceResolverException
fullXPointer - The full XPointer to be processed.InternalReferenceResolverException - if the specified XPointer is malformed.protected static int findClosingBrace(java.lang.String candidate,
int startPos)
throws InternalReferenceResolverException
() in the candidate string, starting at the
specified start position. A closing brace that is escaped with a circumflex character (^)
is ignored.candidate - The string to be investigated.startPos - The position within the candidate string at which the search should start.InternalReferenceResolverException - if there is no closing brace.