Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Grouping nodes into new resultset? Grouping nodes into new resultset?To: NULL Date: 12/2/2004 12:35:00 PM Hi, I'm getting the current XML now with companies along with many codes that can be assigned to the company. I'd like to transfrom the Current to the new layout by grouping the company id, name at the top with the codes nested below. I'm trying the XSLT below but getting the indicated error. I'm using .NET 1.1 Is this possible? Current: <NewDataSet> <row> <CompanyId>677121</CompanyId> <CompanyName>Acme Inc.</CompanyName> <CodeId>20</CodeId> <CodeValue>13445</CodeValue> </row> <row> <CompanyId>677121</CompanyId> <CompanyName>Acme Inc.</CompanyName> <CodeId>29</CodeId> <CodeValue>AMCE</CodeValue> </row> </NewDataSet> To: <NewDataSet> <row> <CompanyId>677121</CompanyId> <CompanyName>Acme Inc.</CompanyName> <Codes> <Code> <CodeId>20</CodeId> <CodeValue>13445</CodeValue> </Code> <Code> <CodeId>29</CodeId> <CodeValue>AMCE</CodeValue> </Code> </Codes> </row> </NewDataSet> The transfrom I'm trying to use to create the new grouping... <?xml version="1.0" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:template match="NewDataSet" mode="grp_company"> <NewDataSet> <xsl:for-each select="row[generate-id() = generate-id(key('company_key', CompanyName)[1])]"> <row> <xsl:sort select="CompanyName"/> <CompanyId><xsl:value-of select="CompanyId"/></CompanyId> <CompanyName><xsl:value-of select="CompanyName"/></CompanyName> <Codes> <xsl:for-each select="key('company_key', CompanyName)"> <Code> <CodeId><xsl:value-of select="CodeId"/></CodeId> <CodeValue><xsl:value-of select="CodeValue"/></CodeValue> </Code> </xsl:for-each> </Codes> </row> </xsl:for-each> </NewDataSet> </xsl:template> </xsl:stylesheet> The error I'm getting on the Transform()? "The specified node cannot be inserted as the valid child of this node, because the specified node is the wrong type." | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
