What is XPointer: XPointer is a specification that allows pointing to nodes in an XML. XLink in dependent on XPointer specification, and so is XPath specification, which is used heavily in XSLT(XML Styling Langage Transformation). XPointer is compact and non-XML, and is designed to be able to fit into a URL (in the fragment part).
What is XML Styling Language Transoformation: It's an XML based language that generates one XML from another. So, what's the point of doing that? You know, XHTML is also XML. The basic idea was to convert the data in XML into a human readable HTML (That's why the name is styling language). But, it can surely be used for other purposes.
Types of XPointers: XPointers are of two types - Shorthand and Scheme based.
Shorthand pointers are very simple. Its just the id of an element. On the other hand, scheme based pointers can be very versatile.
How does XPointer determine the ID: I have already explained in my previous post that the id of an element is not the value of an attribute called id, instead it is the value of attribute with type xsd:ID. However XPointer attempts to cover XML documents whose scheme is expressed in DTD also. In addition to that, even if W3 Schema specification discourages use of the type xsd:ID for an element, it does not forbid it. So, the XPointer specification gives a broader view of id of an element. However, the id here will only select the first element with the same id (it is not mandatory for ids to be unique) in document order (matched by any of the following four checks).
- It checks for attributes of type xsd:ID
- It checks for sub-elements of type xsd:ID.
- it checks of elements with DTD type ID
- A specification that is dependent on XPointer is also allowed to define its own mechanism to determine ID.
The following XML will be used by us for examples.
<employees>
<employee id="emp1">
<name>
<firstname id="f1">John</firstname>
<surname id="s1">Rox</surname>
<id>n1</id>
</name>
<age>29</age>
</employee>
<employee id="emp2">
<name>
<firstname id="f2">Ron</firstname>
<surname id="s2">Bax</surname>
<id>n2</id>
</name>
<age>27</age>
</employee>
<employees>
<employee id="emp1">
<name>
<firstname id="f1">John</firstname>
<surname id="s1">Rox</surname>
<id>n1</id>
</name>
<age>29</age>
</employee>
<employee id="emp2">
<name>
<firstname id="f2">Ron</firstname>
<surname id="s2">Bax</surname>
<id>n2</id>
</name>
<age>27</age>
</employee>
<employees>
Here we will assume that both the attribute id and element id are of type xsd:ID.
Scheme Based Pointer: A scheme based pointer is a sequence of one or more pointer parts optionally separated by space. A pointer part consists of a scheme name and some scheme data in a pair of parentheses [schemename(schemedata)]. The syntax of scheme data depends on the scheme.
Scheme Name: The scheme name is a qualified name. It means that it consists of a namespace and a name. Unqualified scheme names are reserved for W3C defined specifications.
There are existing schemes element, xmlns and xpointer. Other non-standard schemes can also be used by specific applications/other specifications.
The element Scheme: The scheme name element is unqualified. The syntax of scheme data is very simple. One syntax is just like shorthand pointer, as in the following.
#element(f1)
Another form is to have a child sequence. The child sequence is a step wise navigation. For example the following pointer points to the element with id f2
#element(/1/2/1/1)
Note that its not legal to have redundant zeros. For example #element(1/02/01/1) is not legal.
The sequence may also start from an id. So the following sequence points to the element with id f2.
#element(n2/1)
I will get back very soon with more schemes.
Reference:
http://www.w3.org/TR/xptr-framework/
http://www.w3.org/TR/xptr-element/
0 comments:
Post a Comment