Hi Grant,
On Mon, Jul 28, 2008 at 3:48 PM, Focas, Grant
<[EMAIL PROTECTED]> wrote:
> Is there a way in XSLT to loop through the ancestors until I find
> the first instance of a node called "foo"?
>
> For context what I'm trying to do is see if a "bookmark" is in the same
> "section" as the link/@href (and to find this out when I'm processing
> the link).
First I've just got a few questions... you've got nested section tags
so what if the bookmark was in the parent section? Is that the same as
if it's in a following section? (if not then can you give a few more
XML file examples).
If the first ancestor section is all that matters then an approach
would be to compare the generate-id()s of an ancestor section of the
link to the ancestor section of the bookmark. So you'd do something
like (from memory, untested code)
<xsl:key name="bookmarkById" match="bookmark" use="@id"/>
<xsl:template match="link">
<xsl:choose>
<xsl:when test="generate-id(ancestor::section[1]) =
generate-id(key('bookmarkById', substring(@href,
1)[1]/ancestor::section[1])">it's the same section</xsl:when>
<xsl:otherwise>it's not the same section</xsl:otherwise>
</xsl:choose>
</xsl:template>
.Matthew Holloway
http://holloway.co.nz/
*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************