Re: [xsl] Using Xlink and XPointer with XSLT

Subject: Re: [xsl] Using Xlink and XPointer with XSLT
From: Daniel Veillard <Daniel.Veillard@xxxxxxx>
Date: Fri, 20 Apr 2001 12:55:21 +0200
On Fri, Apr 20, 2001 at 11:27:50AM +0200, Jens Schäfers wrote:
> Hello,
> I have a question regarding the use of XLink and XPointer with XSLT.

  Ouch ... some good but hard questions have to be asked from time to
time ...

> My XML document A uses XLinks and XPointer to refer to external elements
> and attributes of another XML document B.
> I want my XSLT stylesheet to use these links to access elements and
> attributes in XML document B when processing XML document A.
> Is this possible?

  Let's try to be precise:
   - about using XLink, answer should be yes. Basically XSLT is agnostic
     on the actual content of the data processed, you can perfectly design
     XSLT pattern to catch XLink elements (the have an xlink:type attribute
     with xlink being associated to the XLink namespace), and then process
     them accordingly to your needs. You will need to put some XLink logic
     within your XSLT program but adding direct support in XSLT wasn't
     possible and I doubt it's actually a good idea (keep thing generic
     is better IMHO).

   - about using XPointer, well once you have detected an URI Reference
     in one of the document constructs (be it XLink or something else)
     the only way to process the refernced resource is to use document()

     12.1 Multiple Source Documents

     deals precisely with this case:
     If the URI reference does contain a fragment identifier, the function
     returns a node-set containing the nodes in the tree identified by
     the fragment identifier of the URI reference. The semantics of the
     fragment identifier is dependent on the media type of the result of
     retrieving the URI. If there is an error in processing the fragment
     identifier, the XSLT processor may signal the error; if it does
     not signal the error, it must recover by returning an empty node-set.

     XPointer itself is not finalized and the binding of XPointer as 
     the syntax and semantic of the fragment identifier for an XML resource
     is not cast in stone either.
     However if you use only a name as the fragment identifier then the
     semantic can be considered 'stable' since just for HTML->XHTML
     compatibility a fragment identifier consisting of a Name should have
     the simple semantic of locating the element carrying the ID of that
     name (i.e. the equivalent of the XPath expression "id(name)").
 The next question is 'how many XSLT processors support this', and
the only answer I know is that it is not currently in libxslt (which
is a shame since I have an XPointer implementation in libxml and doing
it would probably amount to less than one hour of work).

  hope this helps,


Daniel Veillard      | Red Hat Network
veillard@xxxxxxxxxx  | libxml Gnome XML XSLT toolkit | Rpmfind RPM search engine

 XSL-List info and archive:

Current Thread