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
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