[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: a number of values
"Dionisio Ruiz de Zarate" <dionisio@xxxxxxxxxxxxx> wrote in message news:005701c2aeb8$b1b74a30$0201a8c0@xxxxxxx > 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|