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

Re: Count Ancestors Up To But Not Including a Given Ty

Subject: Re: Count Ancestors Up To But Not Including a Given Type
From: Eliot Kimber <ekimber@xxxxxxxxxxxx>
Date: Tue, 05 Feb 2008 09:09:41 -0600
Re:  Count Ancestors Up To But Not Including a Given Ty
David Carlisle wrote:

<xsl:stylesheet version="2.0"

<xsl:function name="f:same" as="element()*"> <xsl:param name="n" as="element()"/> <xsl:sequence select="$n,$n/../..[node-name(.)=node-name($n)]/f:same(.)"/> </xsl:function>

<xsl:template match="y">
:<xsl:value-of select="count(f:same(../..)/name())"/>

These are very helpful examples--I find the select="x,f(x)" construct quite elegant (and familiar now that I remember my old lisp/DSSSL training).

But I realize I didn't give the full story, which is that the number of ancestors between a given list item and its parent list is variable, in that DITA allows both:




So a simple "../.." won't be reliable. (Although one could argue that the intervening <p> should restart the list sequence--I'm not sure the DITA 1.1 spec is clear on that point.)

In thinking about it more I don't think there's a way to generalize this to a query that is not DTD-specific since you have to know which intervening elements to ignore and which to respect.



Eliot Kimber
Senior Solutions Architect
"Bringing Strategy, Content, and Technology Together"
Main: 610.631.6770

Current Thread


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.
First Name
Last Name
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.