Subject: Re: [xsl] Iterative variation of attributes From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 03 Mar 2004 07:43:16 -0500 |
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?¿?
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: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@xxxxxxxxxxxxxxxxxxxx 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Iterative variation of attrib, i92agcad | Thread | Re: [xsl] Iterative variation of at, David Carlisle |
[xsl] Iterative variation of attrib, i92agcad | Date | RE: [xsl] Iterative variation of at, Jarno . Elovirta |
Month |