This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Can you pass a parameter from a stylesheet to the resultingHTML file?
- From: Joerg Heinicke <joerg dot heinicke at gmx dot de>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 04 Jun 2002 20:55:30 +0200
- Subject: Re: [xsl] Can you pass a parameter from a stylesheet to the resultingHTML file?
- References: <113A7A0D1F47D511B92E00D0B7E03DAB0235B5B7@pmail02.vikingfreight.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hello Kathryn,
add these templates to the stylesheets:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
version="1.0">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xhtml:ol[@start='var']">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="start">
<xsl:value-of select="count(preceding::xhtml:ol/xhtml:li) + 1"/>
</xsl:attribute>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
The second xsl file filters out any <li> item with a class of "mgronly":
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
version="1.0">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xhtml:ol[@start='var']">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="start">
<xsl:value-of
select="count(preceding::xhtml:ol/xhtml:li[not(@class='mgronly')]) + 1"/>
</xsl:attribute>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xhtml:li[@class='mgronly']"/>
</xsl:stylesheet>
Here's what I'm trying to do: In the first transformation, I need to
replace "var" in the second <ol> tag with "4".
In the second transformation, because one of the preceding <li> items is
filtered out, I need to replace "var" with "3". (I don't need to have the
XSL files count the <li> items to compute the "4" and "3", unless it's very
easy. I can just hard code "4" and "3".) Is there a way to do this?
Thanks again for all your help--
Kathryn
Regards,
Joerg
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list