Emily(_dot_)Garrett(_at_)thomson(_dot_)com 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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--