Subject: Re: [xsl] Are these two the equivalent? From: tcn@xxxxxxxxxxxxx (Trevor Nash) Date: Sun, 14 Oct 2001 14:49:58 GMT |
On Sun, 14 Oct 2001 14:25:29 +0200, Nicholas Waltham wrote: >Hello All, >I have two ways of what I think should achieve the same result > >Example 1 gives me what I want, Example 2 does not. To me they are the >same...If they are different, could someone explain to me why the second >does not give me what I want. > In XSLT '|' is the union operator, and its operands must be node-sets. @style='L1' yields a boolean, so the second example isn't even legal - your processor should be giving you an error message to that effect. You probably mean ' or ' here rather than '|'. With that change, the two look the same to me though the second will probably run faster. Could be wrong though, I did not spend much time on it. preceding-sibling::p[last()] is also the same as ../p[1] (the first p child of this node's parent) is that what you meant? Its handy to know that XPath expressions (and XML attributes in general) can have white space in them, including newlines. Use them! >Thanks in advance, >Nicholas Waltham > > > > >Example 1: ><xsl:template >match="p[@style='L1'][preceding-sibling::p[last()][@style='L1']|preceding-si >bling::p[last()][@style='L2']|preceding-sibling::p[last()][@style='L3']]"> ><xsl:apply-templates/> ></xsl:template> > >Example 2: ><xsl:template >match="p[@style='L1'][preceding-sibling::p[last()][@style='L1'|@style='L2'|@ >style='L3']]"> ><xsl:apply-templates/> ></xsl:template> > > Regards, Trevor Nash -- Traditional training & distance learning, Consultancy by email Melvaig Software Engineering Limited voice: +44 (0) 1445 771 271 email: tcn@xxxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Are these two the equival, Jörg Heinicke | Thread | Re: [xsl] Are these two the equival, David Carlisle |
Re: [xsl] Are these two the equival, Jörg Heinicke | Date | Re: [xsl] Are these two the equival, David Carlisle |
Month |