RE: xsl self-documentation on the fly (Perl?)

Subject: RE: xsl self-documentation on the fly (Perl?)
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Sat, 24 Jun 2000 11:22:29 +0100

>Thanks again for the info.  My question is now, say you are using method #2
>and are sending xsl-induced changed to stderr.  What I want to put is:
>4. [most importantly] parent elements of that element
>we want written in the log:
>4. library:books:book:author
>   [or some such tree-climbing notation showing the top node to the bottom]

That was roughly what (part of) the 'log-template' template that I gave you

  <!-- this cribbed and slightly modified for 
       human-readability in the log from a
       David Carlisle contribution            -->
  <xsl:for-each select="ancestor-or-self::*">
    <xsl:variable name="nodename" select="name()" />
    <xsl:value-of select="$nodename" />
      select="1 + count(preceding-sibling::*[name() = $nodename])"/>

This bit would generate (from your example):


which is the precise XPath to the author element that is being processed.
I used the positional predicates so that if, say, you had more than one
book, or more than one author of a particular book, you could identify
which one was being processed.  I used XPath syntax because it's designed
to pinpoint nodes and using something that's already there is less work
than making up your own.  

To generate the syntax that you want, you should use:

  <xsl:for-each select="ancestor-or-self::*">
    <xsl:if test="position() > 1">
    <xsl:value-of select="name()" />

If you put this within a named template like the one I suggested, then you
can send the results to stderr using:

    <xsl:call-template select="log-template">
      <!-- relevant parameters -->

Sorry I didn't make this more explicit in my previous message.  Out of
interest, can you let me know how you capture the stderr into a file?



 XSL-List info and archive:

Current Thread