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

Re: When to use conditional constructions?

Subject: Re: When to use conditional constructions?
From: Graydon <graydon@xxxxxxxxx>
Date: Mon, 31 Mar 2014 12:32:19 -0400
Re:  When to use conditional constructions?
On Mon, Mar 31, 2014 at 05:08:09PM +0100, Michael Kay scripsit:
> > While we're extending XPath, can we have support for named, referenceable
> > predicate definitions?  
> 
> Isn't that the same thing as a function?

The case I'm thinking of is something like

<xsl:template
match="section[heading][body/table][body/para[following-sibling:table]][not(body/para[preceding-sibling:table])]">....</xsl:template>

<xsl:template
match="section[heading][body/table][body/para[following-sibling:table]][body/para[preceding-sibling:table]]">....</xsl:template>

<xsl:template
match="section[heading][body/table][not(body/para)]]">....</xsl:template>

Where one's making a distinction between "the normal sections", "the
normal sections with normal tables", "the sections with weird tables",
and "the stuff that really shouldn't be a section but no one has had a
better idea"; it would be very convenient to be able to give the
(generally longer and more complex than presented) predicates meaningful
names and be able to lump them together, since the test tends to get
re-used at least a couple of times.  (Once for processing and once for
the table of contents and maybe once or twice where children are being
processed and the distinction needs to be maintained, so it would be
helpful to be able to go "ancestor::section[%normalSection%]" (or some
less awful syntax...))

<xsl:template
match="section[user:isNormalSection(.)]">...</xsl:template>

and so on seems heavy and expensive compared to effectively a macro
language for predicates; the perceived problem is that the predicates
get long and tough to manage, rather than lack of expressiveness or
power in the predicates.

-- Graydon

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.