[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] When to use text()
Subject: Re: [xsl] When to use text() From: Ihe Onwuka <ihe.onwuka@xxxxxxxxx> Date: Fri, 21 Mar 2014 16:29:56 +0000 |
On Fri, Mar 21, 2014 at 4:21 PM, David Carlisle <davidc@xxxxxxxxx> wrote: > On 21/03/2014 15:28, Ihe Onwuka wrote: >> >> You see an hour ago I wast quite content with my >> >> <xsl:template match="RentAmount | MonthlyAmounts"> <xsl:attribute >> name="class" select="'money'"/> <xsl:apply-templates/> >> </xsl:template> > > > > You shouldn't have been really as warnings about over-use of text() come > up fairly often:-) > > last time though the comments were dismissed with > >> This is why I don't like to post code, because all I really needed >> from this thread was confirmation that duplicate elimination only >> applied to node identity rather than content. > > You took me too literally. I am still content with it because it still works. > >> >> Meanwhile ...... if a comment node did infiltrate RentAmount/text() >> what effect wolud that have with the match pattern and how >> consistent would it be with the equivalent scenario outside a match >> pattern. > > > You apply > > > <xsl:template match="RentAmount/text() | MonthlyAmounts/text()"> > <xsl:value-of select="format-number(.,if (xs:decimal(.) > 999.99) > then '$,000.00' else '$0.00')"/> > </xsl:template> > > to each text node so if you have > > <RentAmount>12<!--3-->4</RentAmount> > > There are two text nodes so you will get > > $12.00$4.00 > > If you had instead had > > > <xsl:template match="RentAmount| MonthlyAmounts"> > <xsl:copy> > > <xsl:value-of select="format-number(.,if (xs:decimal(.) > 999.99) > then '$,000.00' else '$0.00')"/> > </xsl:copy> > </xsl:template> > > > Then you would get > > <RentAmount>124.00</RentAmount> > Perfect. If ever I am passed rental markup with embedded comments I'll know what to reference.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] When to use text(), David Carlisle | Thread | Re: [xsl] When to use text(), G. Ken Holman |
Re: [xsl] When to use text(), Michael Kay | Date | [xsl] dangling attribute creation (, Andrew Welch |
Month |