[xsl] Re: Iterative variation of attributes

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

> 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"
 exclude-result-prefixes="xsl ext myFun"

  <xsl:import href="E:\xml\msxml\XML
  <xsl:output omit-xml-declaration="yes" indent="yes"/>


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

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

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


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