Subject: Re: [xsl] attribute values as name value pair From: "James A. Robinson" <jimr@xxxxxxxxxxxxxxxxxxxxx> Date: Thu, 26 Feb 2004 18:50:08 -0800 |
Given a input xml of <input> <data>...</data> <table>...</table> </input> Will this do what you want? It's probably not the most efficent since I'm doing n*n for-each loops... :( <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/> <xsl:template match="/"> <data> <xsl:apply-templates select="./input/data"/> </data> </xsl:template> <xsl:template match="data"> <xsl:apply-templates select="./row"/> </xsl:template> <xsl:template match="row"> <xsl:variable name="row_attributes" select="@*"/> <xsl:variable name="column_count" select="position()"/> <xsl:for-each select="/input/table/columns/column"> <xsl:variable name="row_name" select="@name"/> <xsl:element name="row"> <xsl:attribute name="id"> <xsl:value-of select="position() * $column_count"/> </xsl:attribute> <xsl:attribute name="key"> <xsl:value-of select="@value"/> </xsl:attribute> <xsl:attribute name="value"> <xsl:for-each select="$row_attributes"> <xsl:if test="local-name(.) = $row_name"> <xsl:value-of select="."/> </xsl:if> </xsl:for-each> </xsl:attribute> </xsl:element> </xsl:for-each> </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] attribute values as name valu, Tracy | Thread | [xsl] Re: attribute values as name , Sam Byland |
[xsl] attribute values as name valu, Tracy | Date | RE: [xsl] Outputting A tag informat, Josh Canfield |
Month |