[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: producing three sets of output from one file
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|