Subject: Re: [xsl] Controlling process flow in a stylesheet? From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 22 Aug 2014 18:07:53 -0000 |
Hi, There's also the very literal-minded if (exists(A)) then A else $A, if (exists(B)) then B else $B Or ... how about (as long as sequence $A has only one member)...? $A/(current()/A , .[empty(current()/A)] With apologies, it's Friday. Cheers, Wendell On Thu, Aug 21, 2014 at 5:30 PM, Michael Kay mike@xxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > I thought of doing it that way, and I often do it that way, but the function call (a) adds a little bit of abstraction, and (b) can handle the case where there are several A (or B etc) children. > > Michael Kay > Saxonica > mike@xxxxxxxxxxxx > +44 (0) 118 946 5893 > > > > > On 21 Aug 2014, at 19:53, Michael MC<ller-Hillebrand mmh@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > >> Am 21.08.2014 um 19:59 schrieb Michael Kay: >> >>> If the parent has a content model A, B, C, D, and any of the four might be absent, then you could try doing >>> >>> <xsl:apply-templates select="optional(A, $A), optional(B, $B), optional(C, $C), optional(D, $D)"/> >>> >>> where optional(X, Y) is a function that selects X if present or Y otherwise, and $A, $B etc are global variables containing default elements of each type (or some other marker to indicate that the element is absent). >> >> Can the function be avoided by writing >> >> <xsl:apply-templates select="(A, $A)[1], (B, $B)[1], (C, $C)[1], (D, $D)[1]"/> >> >> This method was mentioned earlier in this list and I used it since several times as a method to handle default values. >> >> - Michael >> > -- Wendell Piez | http://www.wendellpiez.com XML | XSLT | electronic publishing Eat Your Vegetables _____oo_________o_o___ooooo____ooooooo_^
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Controlling process flow , Michael Kay mike@xxx | Thread | [xsl] Xpath conundrum for the peeps, Ihe Onwuka ihe.onwuk |
Re: [xsl] Comparing attributes and , Martin Honnen martin | Date | [xsl] Helping with deciding databas, L2L 2L emanuelallen@ |
Month |