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

RE: Avoiding multiple "apply-templates" by creating on

Subject: RE: Avoiding multiple "apply-templates" by creating one variable for the clauses. Is it possible?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 20 Aug 2009 18:18:28 +0100
RE:  Avoiding multiple "apply-templates" by creating on
> >       <xsl:apply-templates select="//blog
> >                            [not($AuthorId) or (author_id = $AuthorId)]
> >                            [not($CategoryId) or (category_id =
$CategoryId)]
> >                            "/>
> 
> I guess I'll finally drop in and add another suggestion since 
> I've been waiting for one of my XSLT students to bring it up 
> but I don't see any of them doing so.
> 
> If you are looking for compactness, I believe the above 
> expression can be reduced to the following in both XSLT 1.0 
> and XSLT 2.0:
> 
>        <xsl:apply-templates select="//blog
>                             [not($AuthorId != author_id)]
>                             [not($CategoryId != $CategoryId)]
>                             "/>
> 

I'm not convinced about this equivalence. If $AuthorId is "Mike", and
author_id is an empty sequence, then

 (a)  not($AuthorId) or (author_id = $AuthorId)  ==>  false

 (b)  not($AuthorId != author_id)  ==>  true

So if the optimizer does this conversion for you, it's wrong!

But it's probably safe if author_id will always be a singleton node-set.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

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.