"Dionisio Ruiz de Zarate" <dionisio(_at_)tinieblas(_dot_)com> wrote in message
news:005701c2aeb8$b1b74a30$0201a8c0(_at_)lpis(_dot_)(_dot_)(_dot_)
I want to put 15 input values.
when i programing i make this:
for(int i=0;i<15;i++){
print (the input);
}
how can i using one xslt template to put 15 input whithout writte
into the
xslt fiel the 15?
thanks
In case you want to to produce 15 *different* "input values", just put
them in your source xml document like this:
<t>
<input>Text1</input>
<input>Text2</input>
<input>Text3</input>
<input>Text4</input>
<input>Text5</input>
<input>Text6</input>
<input>Text7</input>
<input>Text8</input>
<input>Text9</input>
<input>Text10</input>
<input>Text11</input>
<input>Text12</input>
<input>Text13</input>
<input>Text14</input>
<input>Text15</input>
<!-- Maybe more <input>s below -->
</t>
then simply do:
<xsl:for-each select="/*/input[position() < 16]">
<xsl:copy-of select="."/>
</xsl:for-each>
In case you want to produce *the same* "input value" 15 times, you can
use a recursive named template.
Another way to do this is easier and almost mechanical -- use the
"scanIter" template from the FXSL library. One example of such
iteration can be found at:
http://aspn.activestate.com/ASPN/Mail/Message/XSL-List/1475837 (an
action is repeated 100 times).
Here's another, direct example:
xml source (file testScaniter3.xml):
---------------------------------------
<t>
<input>myInput</input>
</t>
transformation (file testScaniter3.xsl):
------------------------------------------
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:vendor="urn:schemas-microsoft-com:xslt"
xmlns:myFun="f:myFun"
exclude-result-prefixes="vendor myFun"
<xsl:import href="iter.xsl"/>
<!-- To be applied on testScaniter3.xml file -->
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:variable name="vmyFun" select="document('')/*/myFun:*[1]"/>
<xsl:template match="/">
<xsl:variable name="vResult">
<xsl:call-template name="scanIter">
<xsl:with-param name="arg1" select="14"/> <!-- times - 1 -->
<xsl:with-param name="arg2" select="$vmyFun"/>
<xsl:with-param name="arg3" select="/t/input"/> <!-- x0 -->
<xsl:with-param name="arg4" select="'input'"/> <!-- El. name
-->
</xsl:call-template>
</xsl:variable>
<xsl:copy-of select="vendor:node-set($vResult)/*/*"/>
</xsl:template>
<myFun:myFun/>
<xsl:template match="myFun:*">
<xsl:param name="arg1" select="/.."/>
<xsl:copy-of select="$arg1/node()"/>
</xsl:template>
</xsl:stylesheet>
Result:
-------
<input>myInput</input>
<input>myInput</input>
<input>myInput</input>
<input>myInput</input>
<input>myInput</input>
<input>myInput</input>
<input>myInput</input>
<input>myInput</input>
<input>myInput</input>
<input>myInput</input>
<input>myInput</input>
<input>myInput</input>
<input>myInput</input>
<input>myInput</input>
<input>myInput</input>
=====
Cheers,
Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list