|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Transforming elements into attributes
Hi,
> Is there a nice 'readable' way to transform elements into attributes?
>
> Currently, I need to copy and paste for each one.
>
> XSL:
>
> <xsl:template match="form">
> <form>
> <xsl:if test="@name">
You probably meant to say to test
<xsl:if test="name">
as you example source has no attributes.
> <xsl:attribute name="name">
> <xsl:value-of select="name"/>
> </xsl:attribute>
> </xsl:if>
> <xsl:if test="@action">
> <xsl:attribute name="action">
> <xsl:value-of select="action"/>
> </xsl:attribute>
> </xsl:if>
> <xsl:if test="@method">
> <xsl:attribute name="method">
> <xsl:value-of select="method"/>
> </xsl:attribute>
> </xsl:if>
> <xsl:apply-templates/>
> </form>
> </xsl:template>
<xsl:template match="form">
<xsl:copy>
<xsl:for-each select="name | action | method">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
Cheers,
Jarno
|
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
|

Cart








