[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Performance with grouping

Subject: RE: Performance with grouping
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 20 Mar 2002 09:32:57 -0000
RE:  Performance with grouping
The following should give the right result and adequate performance:

<xsl:variable name="first" select="/RESPONSES/RESPONSE[1]"/>

<xsl:template match="RESPONSES">
 <residents>
  <xsl:apply-templates/>
 </residents>
</xsl:template>

<xsl:template match="RESPONSE[1]"/>

<xsl:template match="RESPONSE">
  <resident>
  <xsl:for-each select="*">
    <xsl:element name="{$first/*[name()=name(current())]}">
      <xsl:value-of select="."/>
    </xsl:element>
  </xsl:for-each>
  </resident>
</xsl:template>

Not tested.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Maulik Modi
> Sent: 19 March 2002 22:13
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Performance with grouping
> 
> 
> Hi,
> 
> I have the following XML :
> 
> <RESPONSES>
> 	<RESPONSE>
> 		<C0><![CDATA[Res_ID]]></C0>
> 		<C1><![CDATA[Res_Type]]></C1>
> 		<C2><![CDATA[Error]]></C2>
> 	</RESPONSE>
> 	<RESPONSE>
> 		<C0><![CDATA[15760412_105755]]></C0>
> 		<C1><![CDATA[SF-IND]]></C1>
> 		<C2><![CDATA[Unverifiable Service Address]]></C2>
> 	</RESPONSE>
> 	<RESPONSE>
> 		<C0><![CDATA[15930044_106686]]></C0>
> 	</RESPONSE>
> 	<RESPONSE>
> 		<C0><![CDATA[15600408_106431]]></C0>
> 		<C1><![CDATA[SF-IND]]></C1>
> 	</RESPONSE>
> </RESPONSES>
> 
> The actual XML could have several children like C0, C1, 
> C2.......Cn and also
> several RESPONSE tags. I need to dynamically extract the 
> tagname from always
> the first <RESPONSE> node and then do further processing to group each
> node-set into a <resident> tag like:
> 
> <residents>
> 	<resident>
> 		<Res_ID>15760412_105755</Res_ID>
> 		<Res_Type>SF-IND</Res_Type>
> 		<Error>Unverifiable Service Address</Error>
> 	</resident>
> 	<resident>
> 		<Res_ID>15930044_106686</Res_ID>
> 		<Res_Type>SF-IND</Res_Type>
> 	</resident>
> 	<resident>
> 		<Res_ID>15600408_106431</Res_ID>
> 		<Res_Type>SF-IND</Res_Type>
> 	</resident>
> </residents>
> 
> However, what I have working so far is this:
> 
> <residents>
> 	<resident>
> 		<Res_ID>15760412_105755</Res_ID>
> 		<Res_ID>15930044_106686</Res_ID>
> 		<Res_ID>15600408_106431</Res_ID>
> 	</resident>
> 	<resident>
> 		<Res_Type>SF-IND</Res_Type>
> 		<Res_Type>SF-IND</Res_Type>
> 	</resident>
> 	<resident>
> 		<Error>Unverifiable Service Address</Error>
> 	</resident>
> </residents>
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.