[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Implementing XPointer Resolution With saxon:evaluate()


Subject: [xsl] Implementing XPointer Resolution With saxon:evaluate()
From: "W. Eliot Kimber" <eliot@xxxxxxxxxx>
Date: Tue, 13 Aug 2002 17:10:15 -0400

I am working out the design of a simple indirect addressing mechanism
(XIndirect) and I'm trying to implement it using XSLT. The
implementation requires that I be able to recursively resolve XPointers
through one or more intermediate elements in order to resolve an initial
reference into the node set of ultimate targets. I am using Saxon 6.5.2.

Obviously this cannot be done in stock XSLT 1.0 but should be doable
with saxon:evaluate(). However, I have not yet been able to make it work
and I can't figure out why. Also, I suspect that it may still be
impossible.

In my test style sheet I am generating an HTML page that makes explicit
both the resolved links from the initial references to their ultimate
targets as well as each of the intermediate steps through the
indirectors. To express the linkages in HTML I'm using the normal
generate-id() approach in the output:

      <xsl:text>ID of ultimate target: </xsl:text>
      <xsl:variable name="members">
        <xsl:call-template name="resolve-xpointer"/>
      </xsl:variable>
      <xsl:for-each select="$members">
        <a href="#{generate-id()}"
        ><xsl:value-of select="generate-id()"
        /></a><xsl:text>, </xsl:text>
      </xsl:for-each>

Where the "resolve-xpointer" template should resolve the xpointer in the
href= attribute of the current node to a node set of ultimate targets.
However, my implementation of resolve-xpointer uses xsl:copy-of, which
of course isn't going to work because the copy nodes are not the same as
the initial target nodes.

What I can't figure out is how to have the resolve-xpointer template
return the actual nodes referenced, not a copy of them--is this even
possible without writing an extension function that does all the address
resolution? That is, I don't see a way for the value of a template to be
the direct value of a select action, rather than a copy of the value.

Also, why does this fail?:

     <xsl:for-each select="$direct-result">
        <xsl:choose>
          <xsl:when test="xindr:indirector">
            <!-- Never gets here -->

When the context node is "xindr:indirector" (as returned by name())? The
corresponding template match does work. Is this a subtle side effect of
name-space processing? 

If I use test="name() = 'xindr:indirector'" then the when succeeds and I
can verify that the addresses are getting resolved correctly and the
indirection is being correctly recursed through.

Thanks,

Eliot
-- 
W. Eliot Kimber, eliot@xxxxxxxxxx
Consultant, ISOGEN International

1016 La Posada Dr., Suite 240
Austin, TX  78752 Phone: 512.656.4139

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords