[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: FizzBuzz in XSLT 1.0. Help with a 2.0/FXSL soluti

Subject: Re: FizzBuzz in XSLT 1.0. Help with a 2.0/FXSL solution?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 14 Mar 2007 18:09:22 GMT
Re:  FizzBuzz in XSLT 1.0.  Help with a 2.0/FXSL soluti
Of course the hardest part there is

     <xsl:for-each select="xs:integer(substring-before(range,'-')) to
     xs:integer(substring-after(range,'-'))">


which is only needed due to the unstructured input.

If the input were

<fizzbuzz>
    <start>1</start>
    <stop>100</stop>

rather than

<fizzbuzz>
    <range>1-100</range>

You could simplify that greatly.

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xsl:output method="text"/>
   <xsl:template match="fizzbuzz">
       <xsl:value-of separator="" select="
  for $i in start to stop
    return ('&#10;',$i, test/mod[($i mod @value) = @test])
    [not(position() lt last() and . instance of xs:integer)]"/>
   </xsl:template>
</xsl:stylesheet>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.