XSLT Transform Attributes to Elements?

wxdqz

New Member
Is it possible to do the following?Given an ADODB.Recordset (ADO 2.5), transform the attribute based xmlstream (where each column is an attribute of a z:row element) to anelement based stream (where each column is it's own elemement node) ?For example, my query returns the following from SQL Server:<rs:data><z:row ContactName="Rubble, Barney" StatusDate="2001-04-17" /></rs:data>I'd like to apply an XSLT stylesheet to transform it to this:<Data><ContactName>Rubble, Barney</ContactName><StatusDate>2001-04-17</StatusDate></Data>The hard part that I've run into is that I'd like the stylesheet to begeneric enough for any arbirtrary ADO sourced XML stream. I thoughtthis would be easy since they all share the same structure... but I'mstuck on how to code a variable an <xsl:Element name="xxx"> in a waythat inserts the current attribute name.Here's what I've come up with so far:<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/><xsl:template match="*/rs:data" xml:space="default"><xsl:for-each select="z:row"><xsl:element name="Data"><xsl:for-each select="@*"><xsl:variable name="c" select="@name"/><xsl:element name="$c"><xsl:value-of select="*"/></xsl:element></xsl:for-each></xsl:element></xsl:for-each></xsl:template></xsl:stylesheet>However, when I run the transform I get an error that tells me that'this name cannot begin with the $ character'.Does anyone have a suggestion for me?TIA
 
Back
Top