This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: producing three sets of output from one file
- From: "Joerg Heinicke" <joerg dot heinicke at gmx dot de>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Fri, 29 Mar 2002 18:23:07 +0100
- Subject: Re: [xsl] producing three sets of output from one file
- References: <20020329.114641.-1039905.2.eric_k_taylor@juno.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hello Eric,
I think it's not so difficult. In any case you need to parameterize the
stylesheet:
<xsl:stylesheet>
<xsl:param name="audience" select="'A'"/>
<xsl:template match="root">
<xsl:apply-templates select="article"/>
</xsl:template>
<xsl:template match="article">
<!-- .... -->
</xsl:template>
</xsl:stylesheet>
Now you have to compare the level of $audience with the @audience of the
articles. With characters this is a bit difficult, with numbers quite easy.
So, if you can replace A with 1 and B with 2 and so on, the following will
help:
<xsl:stylesheet>
<xsl:param name="audience" select="'1'"/>
<xsl:template match="root">
<xsl:apply-templates select="article[@audience <= $audience]"/>
</xsl:template>
<xsl:template match="article">
<!-- .... -->
</xsl:template>
</xsl:stylesheet>
When using ABC, you have to do the replacing dynamically:
<xsl:apply-templates select="article[translate(@audience,'ABC','123')
<= translate($audience,'ABC','123')]"/>
Hope this helps,
Joerg
> I'm trying produce three sets of output from one set of data, each of
> which are subsets of the preceding. That is, I have:
> <article audience="A">stuff here</article>
> <article audience="B">stuff here</article>
> <article audience="C">stuff here</article>
> <article audience="A">stuff here</article>
> <article audience="A">stuff here</article>
>
> For audience A, I want to include only the A articles; for audience B, I
> want to include both A&B articles, and for audience C, I want to include
> them all. I was preparing to just create three different XSL files and
> then use Instant Saxon to transform with each XSL. However, since the
> output is formatted identically, I suspect there's a much more elegant
> way to do it (perhaps passing some parameter when compiling?), but I'm
> not sure what I would do.
>
> If this is explainable to a beginner, I'd appreciate any help. (Or if
> this is beyond a beginner's ability, I'd appreciate someone telling me
> that... and I'll do the easy three files as I planned and come back to
> this at some point in the future.)
>
> Thanks,
> Eric
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list