Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Grouping nodes into new resultset?

From: Dave@-----------.---------.---
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."


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent