Subject: Re: [xsl] WordML Question and normalize-space() question From: David Carlisle <davidc@xxxxxxxxx> Date: Fri, 19 May 2006 16:52:59 +0100 |
> I'm wondering if it's possible to > normalize all the space without removing the leading and trailing > whitespace? <xsl:variable name="x" select="normalize-space(concat('!',.,'!'))"/> <xsl:value-of select="substring($x,2,string-length($x)-2)"/> I didn't follow all your wordml but the following flattens out any b and i elements (and can easily be extended any list of inline elements. <p> <b> bold <br/> text <i> bold and italic </i> just bold again </b> plain text and images <img src="zzz"/> </p> gets turned into <p> <start-b/> bold <end-b/><br/><start-b/> text <end-b/><start-b/><start-i/> bold and italic <end-i/><end-b/><start-b/> just bold again <end-b/> plain text and images <img src="zzz"/> </p> so all text is now a child of <p>. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:template match="b|i"> <xsl:apply-templates/> </xsl:template> <xsl:template match="text()"> <xsl:for-each select="ancestor::*[self::b|self::i]"> <xsl:element name="start-{name()}"/> </xsl:for-each> <xsl:value-of select="."/> <xsl:for-each select="ancestor::*[self::b|self::i]"> <xsl:sort data-type="number" select="- position()"/> <xsl:element name="end-{name()}"/> </xsl:for-each> </xsl:template> <xsl:template match="*"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> </xsl:stylesheet> ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] WordML Question and norma, Nigel Whitaker | Thread | RE: [xsl] WordML Question and norma, Michael Kay |
Re: [xsl] WordML Question and norma, Nigel Whitaker | Date | [xsl] Select nodes with an attribut, mysrdr-wrk |
Month |