L
Linda
Hi,
Sorry if this is the wrong group I'm posting to. We are using a CMS
which saves all files as .xml. We have an xslt file where we parse
all html tags. At the moment, the CMS sometimes puts in < br / > <
br / > to separate content instead of placing text in < p > tags.
I'm trying to find any instance where a < br > follows a < br >,
however for some reason I'm not getting the syntax quite correct. I'm
just starting out with xsl, so it could be a silly mistake, but I
can't find out a solution.
We use xsl v 1.0. The code that I've tried is:
<xsl:template match="br">
<xsl:choose>
<xsl:when test="preceding-sibling::br[1]"></xsl:when>
<xsltherwise><xsl:copy-of select="."/></xsltherwise>
</xsl:choose>
</xsl:template>
I thought that the [1] is meant to get the immediately preceding
sibling. However it still finds instances where there is a single br.
Can someone help in regards to how to find an immediate preceding
sibling. An example of the code I'm using is:
Text< br />
Text< br />< br />
Text< br />< br />
Text< br />
Text.
It ignores the first < br > instance in the first line (as expected),
but it then finds the last single < br > instance in the 4th line.
Eventually I'm hoping to then move the text in < p > tags (using
preceding-sibling::text()[1]/ following-sibling::text()[1]), but for
the moment I just want to single out the double br.
Regards,
Linda
Sorry if this is the wrong group I'm posting to. We are using a CMS
which saves all files as .xml. We have an xslt file where we parse
all html tags. At the moment, the CMS sometimes puts in < br / > <
br / > to separate content instead of placing text in < p > tags.
I'm trying to find any instance where a < br > follows a < br >,
however for some reason I'm not getting the syntax quite correct. I'm
just starting out with xsl, so it could be a silly mistake, but I
can't find out a solution.
We use xsl v 1.0. The code that I've tried is:
<xsl:template match="br">
<xsl:choose>
<xsl:when test="preceding-sibling::br[1]"></xsl:when>
<xsltherwise><xsl:copy-of select="."/></xsltherwise>
</xsl:choose>
</xsl:template>
I thought that the [1] is meant to get the immediately preceding
sibling. However it still finds instances where there is a single br.
Can someone help in regards to how to find an immediate preceding
sibling. An example of the code I'm using is:
Text< br />
Text< br />< br />
Text< br />< br />
Text< br />
Text.
It ignores the first < br > instance in the first line (as expected),
but it then finds the last single < br > instance in the 4th line.
Eventually I'm hoping to then move the text in < p > tags (using
preceding-sibling::text()[1]/ following-sibling::text()[1]), but for
the moment I just want to single out the double br.
Regards,
Linda