[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Something like this?
Mathieu Malaterre wrote:
Re: [xsl] XML Elements to XML Attributes
Subject: Re: [xsl] XML Elements to XML Attributes From: Andrew Franz <afranz0@xxxxxxxxxxxxxxxx> Date: Sun, 14 Jan 2007 12:40:27 +1100 |
Something like this?
<xsl:template match="td" /> <xsl:template match="td[(position() mod 4) = 0]"> <entry tag="{.}" attribute="{following-sibling::td[1]}" type="{following-sibling::td[2]}" description="{following-sibling::td[3]}" /> </xsl:template>
Mathieu Malaterre wrote:
Hello,
I have a very simple question. I have currently the following xsl script (1). But instead of creating elements I would like to create attributes, something like:
<entry tag="{$1}" attribute="{$2}" type="{$3}" description="{$4}"/>
Where $1-4 are the values coming from the loop at position() respectively 1-4.
Coming from a C/C++ world I would have created variables,
unfortunately I cannot do that with the loop. I must be missing
something trivial to be able to rewrite it correctly in XSL.
Thanks
(1) <entry> <xsl:for-each select="td"> <xsl:variable name="cur_val"> <xsl:value-of select="."/> </xsl:variable> <xsl:choose> <xsl:when test="position() = 1"> <tag d="{$cur_val}"/> </xsl:when> <xsl:when test="position() = 2"> <attribute d="{$cur_val}"/> </xsl:when> <xsl:when test="position() = 3"> <type d="{$cur_val}"/> </xsl:when> <xsl:when test="position() = 4"> <description d="{$cur_val}"/> </xsl:when> <xsl:otherwise> <bug/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </entry>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XML Elements to XML Attribute, Mathieu Malaterre | Thread | Re: [xsl] XML Elements to XML Attri, Florent Georges |
[xsl] XML Elements to XML Attribute, Mathieu Malaterre | Date | [xsl] namespace xmlns="http://www.w, Mathieu Malaterre |
Month |
Keywords