[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: More efficient way than following-sibling?
> I am trying to find a more efficient way to determine if a node has > siblings, and then access the next sibling. > > Currently, I am running the following XSLT code: > > <xsl:if test="$TheNode/following-sibling::node()"> > <xsl:call-template name="GenericTemplate"> > <xsl:with-param name="TheNode" > select="$TheNode/following-sibling::*[1]"/> > </xsl:call-template> > </xsl:if> > > However, this is very expensive, when it comes to large XML documents. > I think in Saxon the above would be very efficient indeed. Do you have evidence that it is inefficient on your chosen processor, or are you just guessing? My only quibble is that you are mixing following-sibling::node() and following-sibling::* - you should almost certainly use the same test in both cases. You might get a (very small) speed-up by using a variable: <xsl:variable name="next" select="$TheNode/following-sibling::*[1]"/> <xsl:if test="$next"> <xsl:call-template name="GenericTemplate"> <xsl:with-param name="TheNode" select="$next"/> </xsl:call-template> </xsl:if> or you might be able to turn your named template into a template rule with a mode, so the whole thing then simplifies to: <xsl:apply-templates select="$TheNode/following-sibling::*[1]" mode="generic"/> Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx 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
|