Subject: Re: [xsl] newline white space From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 19 Jul 2001 18:39:13 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] newline white space, Lisa Rupe | Thread | [xsl] XML - html Conversion, ram ragu |
RE: [xsl] Announcement: Xselerator , HIEBERT,STEVE (HP-Co | Date | Re: [xsl] Searching for an attribut, Robert Koberg |
Month |