[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: xsl self-documentation on the fly (Perl?)
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|