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

Re: n squared behavior with XT for 'preceding' tests?

Subject: Re: n squared behavior with XT for 'preceding' tests?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 21 Jul 1999 17:42:14 +0100 (BST)
xsl squared
One thing you can do is work forwards rather than backwards.


Given input of the form

<test>
	<hd>some heading</hd>
...
	<hd>some heading</hd>
	<hd>some OTHER heading</hd>
..
	<hd>some OTHER heading 5555</hd>
</test>

( about 700 lines in my example)

then each of these put out the hd lines, with the first one of each type
flagged by NEWDOC, but the second one appears to run about twice as fast
on an april xt.

==========================================


<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
  result-ns="">

<xsl:template match="hd">	
	<!-- Check to see if the text of the HD matches
		the previous HD's text -->
	<xsl:choose>
	<xsl:when 
	
test="not(text()=from-preceding-siblings(hd[position()=1])/text())">
		<NEWDOC><xsl:copy>
			<xsl:apply-templates/>	  			
			<!-- Output the tag's attributes 
				and its contents -->
		</xsl:copy></NEWDOC>
	</xsl:when>
	<xsl:otherwise>	
		<xsl:copy><xsl:apply-templates/></xsl:copy>
	</xsl:otherwise>	
	</xsl:choose>			
</xsl:template>


</xsl:stylesheet>
==========================================


<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
  result-ns="">

<xsl:template match="test">
<xsl:apply-templates select="hd[1]"/>
</xsl:template>

<xsl:template match="hd">
<xsl:text>
</xsl:text>
		<NEWDOC>
<xsl:copy>
			<xsl:apply-templates/>	  			
			<!-- Output the tag's attributes 
				and its contents -->
		</xsl:copy>
</NEWDOC>
       <xsl:variable name="x" expr="."/>
       <xsl:apply-templates mode="later" select="from-following-siblings(hd[text()=$x])"/>
       <xsl:apply-templates select="from-following-siblings(hd[not(text()=$x)][1])"/>
</xsl:template>

<xsl:template mode="later" match="hd">
<xsl:text>
</xsl:text>
 <xsl:copy> <xsl:apply-templates/></xsl:copy>  			
</xsl:template>


</xsl:stylesheet>
==========================================


 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.