Subject: Re: [xsl] best practices for using XSLT modes From: "Mukul Gandhi gandhi.mukul@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 6 Dec 2019 05:42:29 -0000 |
Hi Eliot, On Thu, Dec 5, 2019 at 8:21 PM Eliot Kimber ekimber@xxxxxxxxxxxx < xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > but I would replace the choice that acts on different @val values with > templates applied to the @val attribute, i.e.: > > <xsl:template match="a"> > <val><xsl:apply-templates select="@val"/></val> > </xsl:template> > > <xsl:template match="@val[. ge 0]"> > <xsl:value-of select="@val || ': positive'"/> > </xsl:template> > > <xsl:template match="@val[. lt 0]"> > <xsl:value-of select="@val || ': negative"/> > </xsl:template> > Thanks for suggesting this. It looks intuitive. > Note that I handle the bug in the original in that it would produce no > result when @val is "0" (zero). > I actually, deliberately didn't include processing for the case @val being zero (my XML & XSLT codes were merely examples for discussion, and were not a real use case). But thanks, for pointing this fact. > The use of templates rather than xsl:choose makes the code cleaner, I > think, puts the focus at the template level on the @val attribute, which is > the focus of the business logic > I agree. -- Regards, Mukul Gandhi
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] best practices for using , Dimitre Novatchev dn | Thread | Re: [xsl] best practices for using , Piez, Wendell A. (Fe |
Re: [xsl] best practices for using , Dimitre Novatchev dn | Date | [xsl] user defined data elements in, Mukul Gandhi gandhi. |
Month |