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

Re: Iterative variation of attributes

Subject: Re: Iterative variation of attributes
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Thu, 4 Mar 2004 06:37:45 +0100
xsl iterative variable
<i92agcad@xxxxxx> wrote in message
news:1078316053.4045cc153001f@xxxxxxxxxxxxx

> I have a template like this...
>
>  <xsl:template name="dibujaEje">
>
>   <line x1="16%" y1="85%" x2="16%" y2="15%"/>
>   <line x1="17%" y1="85%" x2="17%" y2="15%"/>
>    :    :             :                :
>   <line x1="84%" y1="85%" x2="84%" y2="15%"/>
>   <line x1="85%" y1="85%" x2="85%" y2="15%"/>
>
>  </xsl:template>
>
>
>  The attributes of the element line, x1 and x2 change from 16% to 85%...
>
>  How i could simplify this and haven't to write all the lines?¿?

The following transformation uses the "scanIter" template from FXSL and
produces exactly the wanted result:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:ext="http://exslt.org/common"
 xmlns:myFun="f:myFun"
 exclude-result-prefixes="xsl ext myFun"
 >

  <xsl:import href="E:\xml\msxml\XML
SDK\Samples\Tests\Generic\FP\Fxsl\Exslt-Based\iter.xsl"/>
  <xsl:output omit-xml-declaration="yes" indent="yes"/>

  <myFun:myFun/>

  <xsl:variable name="vmyFun" select="document('')/*/myFun:*[1]"/>

  <xsl:template match="/">

    <xsl:variable name="vrtfValues">
      <xsl:call-template name="scanIter">
        <xsl:with-param name="arg1"
        select="69"/><!-- n -->
        <xsl:with-param name="arg2" select="$vmyFun"/><!-- f -->
        <xsl:with-param name="arg3" select="16"/> <!-- x -->
      </xsl:call-template>
    </xsl:variable>

    <xsl:for-each select="ext:node-set($vrtfValues)/*">
      <line x1="{.}%" y1="85%" x2="{.}%" y2="15%"/>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="myFun:*">
    <xsl:param name="arg1"/>

    <xsl:value-of select="1 + $arg1"/>
  </xsl:template>
</xsl:stylesheet>



Cheers,

Dimitre Novatchev
FXSL developer,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.