[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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
perl xsl count
John,

>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:
>[snip]
>4. [most importantly] parent elements of that element
>
>we want written in the log:
>[snip]
>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
did:

  <!-- 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:text>/</xsl:text>
    <xsl:value-of select="$nodename" />
    <xsl:text>[</xsl:text>
    <xsl:value-of
      select="1 + count(preceding-sibling::*[name() = $nodename])"/>
    <xsl:text>]</xsl:text>
  </xsl:for-each>

This bit would generate (from your example):

  /library[1]/books[1]/book[1]/author[1]

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:text>:</xsl:text>
    </xsl:if>
    <xsl:value-of select="name()" />
  </xsl:for-each>

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

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

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?

Thanks,

Jeni


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.