I haven't tested, but you might try:

child::node()[self::* or string-length(normalize-space(.)) > 0]
[position()=last()][self::text()]

I'm guessing that if you have an element at the end of your paragraph, you 
probably have whitespace after that element.  The child::node() axis would 
also return the text node representing that space, and so the last node is 
always a text node.  So the first predicate makes it so that 
[position()=last()] is only applied on elements or text nodes that have 
non-whitespace.

If you've already accounted for all that, then, well, I'm at a loss for 
ideas. :)

It's also probably better to use self::text() instead of "=text()", since the 
'=' sign is used to compare *all* of the child nodes matching text(), instead 
of just one; self::text() is probably more efficient.

On Thursday 21 February 2002 05:29, Anders Samuelson wrote:
> I have the following template snippet:
>
> <xsl:template match="paragraph">
>                       <xsl:apply-templates/>
>                 <xsl:if test="child::node()[position()=last()]=text()">
>                 <xsl:call-template name="br"/>
>         </xsl:if>
> </xsl:template>
>
> The purpose is that the 'br' template should only be called if the last
> child node of the paragraph element is a text node. This wok fine with
> Microsoft XML Parser 3.0 but not with xalan 2.0.0 (or 2.3.0 fo that
> matter). With xalan the test argument is always true (as far as i can tell
> from my tests).

-- 
Peter Davis

Reply via email to