[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
I tried the following 2.0 stylesheet, and it works:
<xsl:output method="text" />
</xsl:stylesheet>
The input XML is:
On 3/14/07, M. David Peterson <m.david@xxxxxxxxxx> wrote:
Re: [xsl] FizzBuzz in XSLT 1.0. Help with a 2.0/FXSL solution?
Subject: Re: [xsl] FizzBuzz in XSLT 1.0. Help with a 2.0/FXSL solution? From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx> Date: Wed, 14 Mar 2007 23:59:06 +0530 |
I tried the following 2.0 stylesheet, and it works:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:output method="text" />
<xsl:template match="fizzbuzz"> <xsl:variable name="range.start" select="xs:integer(substring-before(range,'-'))" /> <xsl:variable name="range.end" select="xs:integer(substring-after(range,'-'))" /> <xsl:variable name="t" select="test" /> <xsl:for-each select="$range.start to $range.end"> <xsl:value-of select="if (((. mod $t/mod[1]/@value) = $t/mod[1]/@test) and ((. mod $t/mod[2]/@value) = $t/mod[2]/@test)) then concat($t/mod[1], $t/mod[2]) else if ((. mod $t/mod[1]/@value) = $t/mod[1]/@test) then $t/mod[1] else if ((. mod $t/mod[2]/@value) = $t/mod[2]/@test) then $t/mod[2] else ." /> <xsl:text> </xsl:text> </xsl:for-each> </xsl:template>
</xsl:stylesheet>
The input XML is:
<?xml version="1.0" encoding="UTF-8"?> <fizzbuzz> <range>1-100</range> <test> <mod value="3" test="0">Fizz</mod> <mod value="5" test="0">Buzz</mod> </test> </fizzbuzz>
On 3/14/07, M. David Peterson <m.david@xxxxxxxxxx> wrote:
Hey All,
Building upon the theme provided by Dr. Kay a while back[1], I recently wrote a post that showcased how one could not only use XSLT to solve the problem, but do so in a way that provides for dynamic data evaluation in regards to the variables used, and what those variables should print out when the test evaluates to true.
http://dev.aol.com/blog/mdavidpeterson/2007/03/14/fizz-buzz-in-xslt-1.0
My question to you all is this: Using this same premise, how would one solve this in XSLT 2.0, and in particular, given that this touches smack-dab center on the benefits that FXSL provides the XSLT developer, how one could use FXSL to solve this same problem?
I been bouncing around different ideas in my head all morning as to the best way to optimize this in XSLT 2.0/FXSL, but as of yet, haven't come up with something that I think really takes advantage of what XSLT 2.0/FXSL bring to the table. Ideas from the community at large?
Thanks in advance!
[1] http://blogs.msdn.com/mfussell/archive/2004/05/13/130969.aspx#131098
"It's a little bit odd to try and prove your point with an example that makes no use of XML input or XML output..."
-- /M:D
M. David Peterson http://mdavid.name | http://www.oreillynet.com/pub/au/2354 | http://dev.aol.com/blog/3155
-- Regards, Mukul Gandhi
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] FizzBuzz in XSLT 1.0. He, M. David Peterson | Thread | Re: [xsl] FizzBuzz in XSLT 1.0. Hel, M. David Peterson |
RE: [xsl] sum() Function Used With , cknell | Date | RE: [xsl] sum() Function Used With , Ryan Lubben |
Month |