Subject: Re: [xsl] suppressing only the last PI From: egarrett@xxxxxxxxxxxx Date: Wed, 03 Jan 2007 16:40:51 -0500 |
Thanks for your help. I am trying to process all nodes, though, not just the PIs. It looks as if I change this, it will only grab the PIs that are not specified, and not the other content. Am I interpreting this correctly? ----- Original Message ----- From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Wednesday, January 3, 2007 3:23 pm Subject: Re: [xsl] suppressing only the last PI To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Emily.Garrett@xxxxxxxxxxx wrote: > > However, the following instruction occurs prior to the content and > > should suppress only the last PI, but is suppressing all processing > > instructions named TL_XSL and whose value beings with 'PageEnd_' > and not > > just the last one: > > > > <xsl:apply-templates > > select="node()[not(self::processing-instruction('TL_XSL')[starts- > with(.,> 'PageEnd_')][position()=last()])]"/> > > > > Can anyone tell what is wrong with it and why it is not just > suppressing> the last one? > > Hi Emily, > > Instead of not(), use position != last(). Like this: > > node()[self::processing-instruction('TL_XSL') > [starts-with(.,'PageEnd_')]][position()!=last()] > > Using the function not() returns true if the so-called effective > boolean > value of the argument returns false. In your case, the instruction > inside the brackets is an xpath expression that always returns > something > when at a processing instruction. The reverse being false. This > has to > do with shifting the square brackets. This becomes apparent when > dissecting your expression: > > node() > [not > ( > self::processing-instruction('TL_XSL') > [starts-with(., 'PageEnd_')] > [position()=last()] > ) > ] > > Remove not() and proc-instr() for clarity leaves: > > 1) node()[[starts-with(., 'PageEnd_')] > 2) [position()=last()]] > > Look closely at the square brackets. It says: "In the current > node, select all that starts with PageEnd, and if so, select the > last one you find". Effectively, you select a "group of one node > and take its last node", which is always true (for nodes that > start with PageEnd that is). > > Reverse that, and it is always false. > > If you want to use not(), you can do so, but put the brackets in > the right position, and reverse only the part you want to reverse > (namely, the test for last()): > > node() > [self::processing-instruction('TL_XSL')] > [starts-with(., 'PageEnd_')] > [not(position()=last())] > > But I'd find it more readable using != instead of not(), but > that's a matter of taste. > > HtH, > > Cheers, > -- Abel Braaksma > http://www.nuntia.nl
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] suppressing only the last, Abel Braaksma | Thread | Re: [xsl] suppressing only the last, Abel Braaksma |
Re: [xsl] String literals with both, Abel Braaksma | Date | RE: [xsl] String literals with both, Michael Kay |
Month |