|
[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?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








