Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] suppressing only the last PI

From: egarrett@------------
To:
Date: 1/3/2007 9:44:00 PM
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent