RE: How to output a subset of preceeding nodes

Subject: RE: How to output a subset of preceeding nodes
From: "Steve Carton" <scarton@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 8 Sep 2000 14:21:52 -0400
Actually, I should have posted back, but I found a solution using keys.
Kind of interesting, because the footnote elements I want to output can
appear at virtually any level in the document hierarchy and they could be
output from any level as well (though only from one template).  So here's
what worked:

Make an index for every possible "FN element, tying it to any "P" element to
the "right"

<xsl:key name="fn" match="//FN" use="generate-id(following::P)"/>
<xsl:key name="fn" match="//FN" use="generate-id(ancestor::P)"/>

Now, the template rule that causes the footnotes to be output:

<xsl:template match="P">
<P/><xsl:apply-templates />
<xsl:call-template name="Dump Footnotes">
<xsl:with-param name="fn" select="key('fn', generate-id(.))"/>
</xsl:call-template>
</xsl:template>

And the template to actually do the output (interestingly, in this data, the
FN elements have a P child!)

<xsl:template name="Dump Footnotes">
<xsl:param name="fn"/>
	<xsl:for-each select="$fn">
		<hr width="30%" align="left" />
		<sup><A NAME="#FN {@N}"></A><xsl:value-of
select="@N"/>.</sup><P/><xsl:value-of select="P"/>
	</xsl:for-each>
</xsl:template>

And the FN template (which, for completeness, creates the HTML link to the
footnote in place:

<xsl:template match="FN">
<sup><A HREF="#FN {@N}"><xsl:value-of select="@N"/></A></sup>
</xsl:template>

where the N attribute has a specific footnote number. (Thankfully, I don't
also need to create them!)

Thanks for your suggestions



-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Kay Michael
Sent: Friday, September 08, 2000 1:29 PM
To: 'xsl-list@xxxxxxxxxxxxxxxx'
Subject: RE: How to output a subset of preceeding nodes


> What I need to do is to process all FN elements located prior
> to the current<P> element, BUT after the last set of <FN> elements I
> already processed!

There's no way of "remembering" what nodes you've already processed, you
need some kind of function that tells you. Then you want to process

preceding::FN[not(some-condition)]

where "some-condition" is a predicate that tells you if a node is already
processed.

Hope this gives you a pointer in the right direction.

Mike Kay


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


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


Current Thread