[Home] [By Thread] [By Date] [Recent Entries]
Hi Yun Wu,
At 04:07 AM 8/18/2007, you wrote: basically i like to generic produce the following code rather then write it by myself It isn't exactly clear what you actually want. For one, your example isn't well-formed. I am going to assume you want: <class>
<xsl:attribute name="name">
<xsl:text>classA</xsl:text>
</xsl:attribute>
</class>... that is, you want to attach a series of class elements each with an attribute named "name" and a value "classX". Then the next question is will it be simply <class name="classX"/> ? if so, this is just generating a series of elements matching a series of values. Given a series of values X: <x> <value>classA</value> <value>classB</value> ... </value>classX</value> </x> then generating the source is pretty easy stuff, as you can undoubtedly see: you simply select the set of nodes x/* and generate 'class' elements, populating their @name attributes accordingly: (Having bound $values to x/value, depending on the context) <xsl:for-each select="$values">
<class name="{.}"/>
</xsl:for-each>The only question remaining is how you want to make x/value available at runtime. There are many ways to do this; which is most convenient depends on your processing architecture. So you probably need to pose a more specific question, correcting any mistaken assumptions in the above. My guess is you want to do something more complex, and/or you're actually asking about ways to make an arbitrary series of values available at runtime (i.e., how to bind a $values variable). An external document called in with the document() function may be the simplest and most versatile way to do this. Cheers, Wendell
|

Cart



