Re: [xsl] Matching two consecutive <br><br>

Subject: Re: [xsl] Matching two consecutive <br><br>
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 23 Aug 2004 10:32:41 +0100
don't use name() in these kinds of tests:
name(following-sibling::node()[1])='br'
use
following-sibling::node()[1][self::br]

> But this does not work for Xalan 2. 

looks correct to me, when you say it didn't work, what did it do? error?
wrong answer?

When you have a template that is simply an xsl:choose it's often simpler
to break it into two templates@

<xsl:template match="br">one BR</xsl:template>

<xsl:template match="br[following-sibling::node()[1][self::br]]">two BRs</xsl:template>


Note this solution and yours will produce
two BRsone BR
for <br/><br/> as the second one will match the "one" case so you might
want to add

<xsl:template match="br[preceding-sibling::node()[1][self::br]]"></xsl:template>

so that subsequent nodes produce no output.

Also your subject line says <br><br> if you had that as xml then the
second br woul dbe a child of the first so none of these solutions would
work, if on the other hand your input is xml then it would work but in
that case it probably ought to be xhtml in which case the br ought to be
in the XHTML namespaec in which case you would need to declare 
xmlns:h="http://www.w3.org/1999/xhtml"; in your stylesheet and replace
every occurrence of br in your stylesheet by h:br.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread