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

Re: Performance Tuning

Subject: Re: Performance Tuning
From: Bhupendra Singh <skbhupendra@xxxxxxxxxxx>
Date: Wed, 10 Nov 2004 16:17:38 +0000 (GMT)
sibling tuning
Hi,
I am sending the XSLT again with reduced font size
since the lines earlier got screwed up.
 
<xsl:param name="priroot">ParentGroup</xsl:param>
<xsl:param name="secroot">ChildGroup</xsl:param>
<xsl:key name="PRI" match="ParentGroup" use="."/>
<xsl:key name="SEC" match="ChildGroup" use="."/>
 
<CUSTOMER_RELATIONS>
<xsl:variable name="var_1" select="Document/Parent
Group" />
<xsl:variable name="var_2" select="Document/Child
Group" />
<xsl:variable name="var_3" select="Document/Child
Node1" />
<xsl:variable name="var_4" select="Document/Child
Node2" />
<xsl:variable name="var_5" select="Document/Child
Node3" />
 <xsl:for-each select="$var_1[count(. | key('PRI',
.)[1]) = 1]">
  <xsl:element name="{$priroot}">
  <xsl:variable name="priId" select="." />
  <xsl:variable name="p"
select="count(preceding-sibling::ParentGroup) + 1" />
  <PRIMARY_CUST_DESC><xsl:value-of
select="$var_4[$p]"/> </PRIMARY_CUST_DESC>
  <xsl:for-each select="$var_2[count(. | key('SEC',
.)[1]) = 1]">
  <xsl:variable name="m"
select="count(preceding-sibling::ChildGroup) + 1" />
   <xsl:if test="$var_1[$m] = $priId">
   <xsl:variable name="id" select="." />
   <xsl:element name="{$secroot}">
    <xsl:for-each select="$var_2[. = $id]">
    <xsl:variable name="n"
select="count(preceding-sibling::ChildGroup) + 1" />
     <ACCOUNT_SUMMARY>
     <UNIQUE_ID>A<xsl:value-of
select="$n"/></UNIQUE_ID>
     <xsl:copy-of select="." />
     <xsl:copy-of select="$var_3[$n]" />
     <xsl:copy-of select="$var_4[$n]" />
     </ACCOUNT_SUMMARY>
    </xsl:for-each>
   </xsl:element>
   </xsl:if>    
  </xsl:for-each>
  </xsl:element>
 </xsl:for-each>
</CUSTOMER_RELATIONS>



 --- Bhupendra Singh <skbhupendra@xxxxxxxxxxx> wrote: 
> Hi,
> I have an XML something like this.
> <Document>
> 	- <ParentGroup> Node1 </ParentGroup>
> 	- <ChildGroup> Node1.1 </ChildGroup>
> 	- <Child Node1>1.1.1 </Child Node1>
> 	- <Child Node2>1.1.2 </Child Node2>
> 	- <Child Node3>1.1.3 </Child Node3>	
> 	- <ParentGroup> Node1 </ParentGroup>
> 	- <ChildGroup> Node1.2 </ChildGroup>
> 	- <Child Node1>1.2.1 </Child Node1>
> 	- <Child Node2>1.2.2 </Child Node2>
> 	- <Child Node3>1.2.3 </Child Node3>	
> 	- <ParentGroup> Node1 </ParentGroup>
> 	- <ChildGroup> Node1.3 </ChildGroup>
> 	- <Child Node1>1.3.1 </Child Node1>
> 	- <Child Node2>1.3.2 </Child Node2>
> 	- <Child Node3>1.3.3 </Child Node3>	
> 	- <ParentGroup> Node1 </ParentGroup>
> 	- <ChildGroup> Node1.3 </ChildGroup>
> 	- <Child Node1>1.3.x </Child Node1>
> 	- <Child Node2>1.3.y </Child Node2>
> 	- <Child Node3>1.3.z </Child Node3>	
> 
> 	- <ParentGroup> Node2 </ParentGroup>
> 	- <ChildGroup> Node2.1 </ChildGroup>
> 	- <Child Node1>2.1.1 </Child Node1>
> 	- <Child Node2>2.1.2 </Child Node2>
> 	- <Child Node3>2.1.3 </Child Node3>	
> 	- <ParentGroup> Node2 </ParentGroup>
> 	- <ChildGroup> Node2.2 </ChildGroup>
> 	- <Child Node1>2.2.1 </Child Node1>
> 	- <Child Node2>2.2.2 </Child Node2>
> 	- <Child Node3>2.2.3 </Child Node3>	
> 	- <ParentGroup> Node2 </ParentGroup>
> 	- <ChildGroup> Node2.3 </ChildGroup>
> 	- <Child Node1>2.3.1 </Child Node1>
> 	- <Child Node2>2.3.2 </Child Node2>
> 	- <Child Node3>2.3.3 </Child Node3>	
> ...........
> </Document>
> 
> Please note that all the nodes above are at the same
> depth. I want to transform the above XML into depth
> wise soemthing like this:
> 
> <Document>
>   <ParentGroup>	
>   <PRIMARY_CUST_DESC>Node1</PRIMARY_CUST_DESC>
>      <ChildGroup Node1.1 >
> 	<ACCOUNT_SUMMARY>
> 	- <Child Node1>1.1.1 </Child Node1>
> 	- <Child Node2>1.1.2 </Child Node2>
> 	- <Child Node3>1.1.3 </Child Node3>
> 	<ACCOUNT_SUMMARY>
>      </ChildGroup>
>      <ChildGroup Node1.2 >
> 	<ACCOUNT_SUMMARY>
> 	- <Child Node1>1.2.1 </Child Node1>
> 	- <Child Node2>1.2.2 </Child Node2>
> 	- <Child Node3>1.2.3 </Child Node3>
> 	</ACCOUNT_SUMMARY>
>      </ChildGroup>
>      <ChildGroup Node1.3 >
> 	<ACCOUNT_SUMMARY>
> 	- <Child Node1>1.3.1 </Child Node1>
> 	- <Child Node2>1.3.2 </Child Node2>
> 	- <Child Node3>1.3.3 </Child Node3>
> 	</ACCOUNT_SUMMARY>
>      </ChildGroup>
>      <ChildGroup Node1.3 >
> 	<ACCOUNT_SUMMARY>
> 	- <Child Node1>1.3.x </Child Node1>
> 	- <Child Node2>1.3.y </Child Node2>
> 	- <Child Node3>1.3.z </Child Node3>
> 	</ACCOUNT_SUMMARY>
>      </ChildGroup>
>   </ParentGroup>	
>   <ParentGroup>	
>   <PRIMARY_CUST_DESC>Node2</PRIMARY_CUST_DESC>
>     <ChildGroup Node2.1 >
> 	<ACCOUNT_SUMMARY>
> 	- <Child Node1>2.1.1 </Child Node1>
> 	- <Child Node2>2.1.2 </Child Node2>
> 	- <Child Node3>2.1.3 </Child Node3>
> 	</ACCOUNT_SUMMARY>
>     </ChildGroup>
>     <ChildGroup Node2.2 >
> 	<ACCOUNT_SUMMARY>
> 	- <Child Node1>2.2.1 </Child Node1>
> 	- <Child Node2>2.2.2 </Child Node2>
> 	- <Child Node3>2.2.3 </Child Node3>
> 	</ACCOUNT_SUMMARY>
>     </ChildGroup>
>     <ChildGroup Node2.3 >
> 	<ACCOUNT_SUMMARY>
> 	- <Child Node1>2.3.1 </Child Node1>
> 	- <Child Node2>2.3.2 </Child Node2>
> 	- <Child Node3>2.3.3 </Child Node3>
> 	</ACCOUNT_SUMMARY>
>     </ChildGroup>
>   </ParentGroup>	
> ...........
> </Document>
> 
> 
> The XSL that I use has  three "preceding-sibling::"
> The time taken to parse a 150KB XML in Xalan is 1.9
> sec and with Saxon8 its 1.6 secs.
> 
> Since the above parsing is done frequently in my
> application with different input XMLs. I need to
> further reduce the transformation timing (in
> milliseconds may be). The only bottleneck I see are
> the 3 preceding-sibling. Can we somehow remove them
> or
> use some other logic, to reduce my transformation
> time.
> 
> Here is the XSL:
> 
> <xsl:param name="priroot">ParentGroup</xsl:param>
> <xsl:param name="secroot">ChildGroup</xsl:param>
> 
> <xsl:key name="PRI" match="ParentGroup" use="."/>
> <xsl:key name="SEC" match="ChildGroup" use="."/>
> 
> <CUSTOMER_RELATIONS>
>  <xsl:variable name="var_1"
> select="Document/ParentGroup"/>
>  <xsl:variable name="var_2"
> select="Document/ChildGroup" />
>  <xsl:variable name="var_3" select="Document/Child
> Node1" />
>  <xsl:variable name="var_4" select="Document/Child
> Node2" />
>  <xsl:variable name="var_5" select="Document/Child
> Node3" />
>    <xsl:for-each select="$var_1[count(. | key('PRI',
> .)[1]) = 1]">
>    <xsl:element name="{$priroot}">
> 	<xsl:variable name="priId" select="." />
> 	<xsl:variable name="p"
> select="count(preceding-sibling::ParentGroup) + 1"
> />
> 	<PRIMARY_CUST_DESC><xsl:value-of
> select="$priId"/></PRIMARY_CUST_DESC>
> 	<xsl:for-each select="$var_2[count(. | key('SEC',
> .)[1]) = 1]">
>    	   <xsl:variable name="m"
> select="count(preceding-sibling::ChildGroup) + 1" />
> 	   <xsl:if test="$var_1[$m] = $priId">
> 	   <xsl:variable name="id" select="." />
> 	   <xsl:element name="{$secroot}">
> 	   <xsl:for-each select="$var_2[. = $id]">
> 		<xsl:variable name="n"
> select="count(preceding-sibling::ChildGroup) + 1" />
> 		<ACCOUNT_SUMMARY> 		 	       
> <UNIQUE_ID>A<xsl:value-of select="$n"/></UNIQUE_ID>
> 		<xsl:copy-of select="." />
> 		<xsl:copy-of select="$var_3[$n]" />
> 		<xsl:copy-of select="$var_4[$n]" />
> 		</ACCOUNT_SUMMARY>
> 	   </xsl:for-each>
> 	   </xsl:element>
> 	   </xsl:if>				
> 	</xsl:for-each>
> 	</xsl:element>
>    </xsl:for-each>
> </CUSTOMER_RELATIONS>
> 
> I would appreciate any suggestions to reduce the
> timings.
> 
> Thanks in advance,
> Bhupendra.
> 
> 
> 
> 	
> 	
> 		
>
___________________________________________________________ALL-NEW
> Yahoo! Messenger - all new features - even more fun!
> http://uk.messenger.yahoo.com
> 
>  


		
___________________________________________________________ 
Moving house? Beach bar in Thailand? Win 10k with Yahoo! Mail to make your dream a reality. 
Get Yahoo! Mail http://uk.mail.yahoo.com

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.