Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 25th, 2009, 04:11 PM
Registered User
 
Join Date: May 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Simplifing OR condition

I have check whether h1 or h2 or span comes as ancestor ..is this considered efficient.

test="ancestor::*[local-name() = 'h1' or local-name() = 'h2' or local-name() = 'span']"
 
Old May 26th, 2009, 04:02 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

It is quite hard to answer questions about 'efficiency' without a) indepth knowledge about the XSLT processor in question, b) knowledge of the XML document being processed and c) knowledge of the complete XSLT document.

It is quite possible that this is the most efficient way to do what you want, but I couldn't say that from what you have shown us so far.

For example if the XML document has a huge tree, and the size of the ancestor axis is large then this might be a very inefficient way of doing the check. It may be better to find all h1, h2 and span element and then process their children.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old May 26th, 2009, 04:44 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I agree with Sam. One point, though, is that ancestor::h1 is likely to be a faster test than ancestor::*[local-name()='h1']. It's also cleaner: the whole point about namespaces is that the name "h1" only means anything in the context of a particular namespace.

If your stylesheet is unacceptably slow, it's unlikely that this expression is the problem. (And if it's not, why are you worried?)
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
or condition kgoldvas XSLT 1 July 31st, 2007 03:44 AM
where condition...? mnr555 Crystal Reports 0 June 18th, 2006 05:32 PM
Please check my where condition mat41 SQL Language 4 May 26th, 2006 08:52 AM
if then else condition mateenmohd Classic ASP Basics 0 April 16th, 2005 07:08 AM
Condition mateenmohd SQL Server 2000 6 May 6th, 2004 03:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.