XML for Java Compatibility API 2.0.13

com.ibm.xml.xpointer
Class XPointer

java.lang.Object
  |
  +--com.ibm.xml.xpointer.XPointer

public class XPointer
extends java.lang.Object
implements java.io.Serializable

The XPointer class provides support for addressing into the internal structures of XML documents as defined by WD-xptr-19980303.

An XPointer consists of a series of location terms, each of which specifies a location, usually relative to the location specified by the prior location term. Each location term has a keyword (such as id, child, ancestor, and so on) and can have arguments such as an instance number, element type, or attribute. For example, the location term child(2,CHAP) refers to the second child element whose type is CHAP.

Location terms are classified into absolute terms, relative terms, span terms, attribute terms, and string data terms. An absolute term selects one or more elements or locations in an XML document without reference to any other sub-resource location. A relative or string data term specifies a location in terms of another location, called the location source . The location source is the entire resource if there are no preceding location terms; otherwise it is the location specified by the preceding term (which might be relative to a location term before that).

Version:
Revision: 23 1.5 src/com/ibm/xml/xpointer/XPointer.java, parser, xml4j2, xml4j2_0_13
See Also:
AbsTerm, RelTerm, SpanTerm, AttrTerm, StringTerm, Serialized Form

Field Summary
static java.lang.String[] literals
           
static java.lang.String[] nodetypes
           
static int NT_ALL
           
static int NT_CDATA
           
static int NT_COMMENT
           
static int NT_ELEMENT
           
static int NT_NAME
           
static int NT_NONE
           
static int NT_PI
           
static int NT_TEXT
           
static java.lang.String S_ALL
           
static java.lang.String S_CDATA
           
static java.lang.String S_COMMENT
           
static java.lang.String S_ELEMENT
           
static java.lang.String S_END
           
static java.lang.String S_IMPLIED
           
static java.lang.String S_NIMPLIED
           
static java.lang.String S_PI
           
static java.lang.String S_TEXT
           
static int ST_ANCESTOR
           
static int ST_ATTR
           
static int ST_CHILD
           
static int ST_DESCENDANT
           
static int ST_FOLLOWING
           
static int ST_FSIBLING
           
static int ST_HTML
           
static int ST_ID
           
static int ST_NONE
           
static int ST_ORIGIN
           
static int ST_PRECEDING
           
static int ST_PSIBLING
           
static int ST_ROOT
           
static int ST_SPAN
           
static int ST_STRING
           
static int T_ANY
           
static int T_EXACT
           
static int T_IMPLIED
           
static int T_NAME
           
 
Constructor Summary
XPointer(AbsTerm absTerm, java.util.Vector otherTerms)
          Constructor.
 
Method Summary
 void appendOtherTerm(OtherTerm otherTerm)
          Appends the specified otherTerm to the end of the other terms for this XPointer.
 AbsTerm getAbsTerm()
          Returns the absolute location term of this XPointer.
 java.util.Vector getOtherTermsVector()
          Returns a Vector of Relterm, SpanTerm, AttrTerm, and StringTerm items which comprise the other terms of this XPointer.
 void insertOtherTerm(OtherTerm otherTerm)
          Inserts the specified otherTerm to the beginning of the other terms for this XPointer.
static XPointer makeXPointer(Child targetNode)
          Returns an XPointer instance representing the specified targetNode.
 Pointed point(org.w3c.dom.Document document)
          Returns the locations in the specified document that are satisfied by this XPointer.
 Pointed point(org.w3c.dom.Node originNode)
          Returns the locations in the specified originNode that are satisfied by this XPointer.
 OtherTerm removeLastOtherTerm()
          Returns and removes the OtherTerm at the end of this XPointer.
 void setAbsTerm(AbsTerm absTerm)
          Sets the absolute location term of this XPointer.
 java.lang.String toString()
          Returns this XPointer in the form of either: absoluteTerm absoluteTerm.otherTerm absoluteTerm.otherTerm.otherTerm... otherTerm otherTerm.otherTerm...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

S_ALL

public static final java.lang.String S_ALL

S_END

public static final java.lang.String S_END

NT_NONE

public static final int NT_NONE

NT_NAME

public static final int NT_NAME

NT_ELEMENT

public static final int NT_ELEMENT

NT_PI

public static final int NT_PI

NT_COMMENT

public static final int NT_COMMENT

NT_TEXT

public static final int NT_TEXT

NT_CDATA

public static final int NT_CDATA

NT_ALL

public static final int NT_ALL

nodetypes

public static final java.lang.String[] nodetypes

S_ELEMENT

public static final java.lang.String S_ELEMENT

S_PI

public static final java.lang.String S_PI

S_COMMENT

public static final java.lang.String S_COMMENT

S_TEXT

public static final java.lang.String S_TEXT

S_CDATA

public static final java.lang.String S_CDATA

S_NIMPLIED

public static final java.lang.String S_NIMPLIED

S_IMPLIED

public static final java.lang.String S_IMPLIED

literals

public static final java.lang.String[] literals

ST_NONE

public static final int ST_NONE

ST_ROOT

public static final int ST_ROOT

ST_ORIGIN

public static final int ST_ORIGIN

ST_ID

public static final int ST_ID

ST_HTML

public static final int ST_HTML

ST_CHILD

public static final int ST_CHILD

ST_DESCENDANT

public static final int ST_DESCENDANT

ST_ANCESTOR

public static final int ST_ANCESTOR

ST_PRECEDING

public static final int ST_PRECEDING

ST_PSIBLING

public static final int ST_PSIBLING

ST_FOLLOWING

public static final int ST_FOLLOWING

ST_FSIBLING

public static final int ST_FSIBLING

ST_SPAN

public static final int ST_SPAN

ST_ATTR

public static final int ST_ATTR

ST_STRING

public static final int ST_STRING

T_IMPLIED

public static final int T_IMPLIED

T_ANY

public static final int T_ANY

T_NAME

public static final int T_NAME

T_EXACT

public static final int T_EXACT
Constructor Detail

XPointer

public XPointer(AbsTerm absTerm,
                java.util.Vector otherTerms)
Constructor.
Parameters:
absTerm - Absolute term of XPointer. Specification of null is allowed.
otherTerms - A vector of OtherTerm instances. Specification of null is allowed.
See Also:
AbsTerm, OtherTerm
Method Detail

getAbsTerm

public AbsTerm getAbsTerm()
Returns the absolute location term of this XPointer.
Returns:
This XPointer's absolute location term, or null if no absolute term.
See Also:
setAbsTerm(com.ibm.xml.xpointer.AbsTerm), AbsTerm

setAbsTerm

public void setAbsTerm(AbsTerm absTerm)
Sets the absolute location term of this XPointer.
Parameters:
absTerm - This XPointer's absolute location term, or null if no absolute term.
See Also:
getAbsTerm(), AbsTerm

getOtherTermsVector

public java.util.Vector getOtherTermsVector()
Returns a Vector of Relterm, SpanTerm, AttrTerm, and StringTerm items which comprise the other terms of this XPointer.
Returns:
This XPointer's other terms, or null if no other terms.
See Also:
RelTerm, AttrTerm, StringTerm, SpanTerm, OtherTerm, appendOtherTerm(com.ibm.xml.xpointer.OtherTerm), insertOtherTerm(com.ibm.xml.xpointer.OtherTerm), removeLastOtherTerm()

appendOtherTerm

public void appendOtherTerm(OtherTerm otherTerm)
Appends the specified otherTerm to the end of the other terms for this XPointer.
Parameters:
otherTerm - The RelTerm, AttrTerm, StringTerm, or SpanTerm to be appended.
See Also:
RelTerm, AttrTerm, StringTerm, SpanTerm, OtherTerm, getOtherTermsVector(), insertOtherTerm(com.ibm.xml.xpointer.OtherTerm), removeLastOtherTerm()

insertOtherTerm

public void insertOtherTerm(OtherTerm otherTerm)
Inserts the specified otherTerm to the beginning of the other terms for this XPointer.
Parameters:
otherTerm - The RelTerm, AttrTerm, StringTerm, or SpanTerm to be inserted.
See Also:
RelTerm, AttrTerm, StringTerm, SpanTerm, OtherTerm, getOtherTermsVector(), appendOtherTerm(com.ibm.xml.xpointer.OtherTerm), removeLastOtherTerm()

removeLastOtherTerm

public OtherTerm removeLastOtherTerm()
Returns and removes the OtherTerm at the end of this XPointer.
Returns:
The RelTerm, AttrTerm, StringTerm, or SpanTerm that was at the end of this XPointer's other term Vector, or null if there are no existing other terms.
See Also:
RelTerm, AttrTerm, StringTerm, SpanTerm, OtherTerm, getOtherTermsVector(), appendOtherTerm(com.ibm.xml.xpointer.OtherTerm), insertOtherTerm(com.ibm.xml.xpointer.OtherTerm)

toString

public java.lang.String toString()
Returns this XPointer in the form of either:
Returns:
A string represention of this XPointer.
Overrides:
toString in class java.lang.Object
See Also:
AbsTerm.toString(), RelTerm.toString(), AttrTerm.toString(), StringTerm.toString(), SpanTerm.toString()

point

public Pointed point(org.w3c.dom.Document document)
Returns the locations in the specified document that are satisfied by this XPointer.
The following terms of this XPointer are not currently supported:
origin()
html()
span()
string()
Parameters:
document - TXDocument instance to be examined.
Returns:
Matched locations (should never be null).
See Also:
Pointed, Document

point

public Pointed point(org.w3c.dom.Node originNode)
Returns the locations in the specified originNode that are satisfied by this XPointer.
The following terms of this XPointer are not currently supported:
span()
string()
Parameters:
originNode - Node instance to be examined.
Returns:
Matched locations (should never be null).
See Also:
Pointed, Child

makeXPointer

public static XPointer makeXPointer(Child targetNode)
Returns an XPointer instance representing the specified targetNode.
Parameters:
targetNode - Node to be represented as an XPointer.
Returns:
XPointer instance, or null if targetNode can not be represented by an XPointer.
See Also:
Child.makeXPointer()

XML for Java Compatibility API 2.0.13