At 2004-03-03 13:14 +0100, i92agcad(_at_)uco(_dot_)es wrote:
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?¿?
By using a recursive call as illustrated below. Note how the counter
variable is initialized to 16 and gets called again until the 85 is written
out.
I hope this helps.
...................... Ken
T:\ftemp>type es.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output indent="yes"/>
<xsl:template match="/">
<result>
<xsl:call-template name="dibujaEje"/>
</result>
</xsl:template>
<xsl:template name="dibujaEje">
<xsl:param name="counter" select="16"/>
<line x1="{$counter}%" y1="85%" x2="{$counter}%" y2="15%"/>
<xsl:if test="$counter < 85">
<xsl:call-template name="dibujaEje">
<xsl:with-param name="counter" select="$counter + 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
T:\ftemp>saxon es.xsl es.xsl
<?xml version="1.0" encoding="utf-8"?>
<result>
<line x1="16%" y1="85%" x2="16%" y2="15%"/>
<line x1="17%" y1="85%" x2="17%" y2="15%"/>
<line x1="18%" y1="85%" x2="18%" y2="15%"/>
<line x1="19%" y1="85%" x2="19%" y2="15%"/>
... elided by hand ...
<line x1="81%" y1="85%" x2="81%" y2="15%"/>
<line x1="82%" y1="85%" x2="82%" y2="15%"/>
<line x1="83%" y1="85%" x2="83%" y2="15%"/>
<line x1="84%" y1="85%" x2="84%" y2="15%"/>
<line x1="85%" y1="85%" x2="85%" y2="15%"/>
</result>
T:\ftemp>rem Done!
--
US XSL training: Washington,DC March 15; San Francisco,CA March 22
World-wide on-site corporate, government & user group XML training
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list