|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: newline white space
Hi Lisa,
> I'm having some trouble with newline white space. I fixed this once
> before but can't remember for the life of me how!
>
> The XML looks like this:
> <p>This is a para<hyphen/><lb/>
> graph.</p>
The problem is that this XML has a line break in it after the lb
element, so the tree looks like:
+- (element) p
+- (text) This is a para
+- (element) hyphen
+- (element) lb
+- (text) 
graph.
You may want to just normalise all the text nodes to get rid of the
problem:
<xsl:template match="text()">
<xsl:value-of select="normalize-space()" />
</xsl:template>
or perhaps only those that have an lb element as their
immediately-preceding sibling.
> Ideally, there would not be a <hyphen/> tag, but ­, but I
> couldn't figure out how to do that either.
If you have:
<p>This is a para­<lb/>
graph.</p>
Then you need to check whether the last character of the text node
before the lb element is a '­' character to decide what to do.
You can get that last character using the substring() function:
<xsl:template match="lb">
<xsl:variable name="text" select="preceding-sibling::text()[1]" />
<xsl:if test="substring($text, string-length($text)) != '­'">
<fo:inline>
<xsl:text> </xsl:text><xsl:apply-templates />
</fo:inline>
</xsl:if>
</xsl:template>
(BTW, there's no point in applying templates in the lb element if it's
an empty element, as it seems to be in your example.)
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








