Re: Things that make me scream: xml:space="preserve" in WordML

Hi Jeni, I’ve having a bit of a problem and don’t know if its xsl or VS.Net. I’m running a transform in .NET 2.0 and basically processing all elements and if it is a ‘special’ element I do something but if it is a ‘word element’ I basically just try to replicate it, but I can’t use a xsl:copy-of because I need to process its sub elements to see if there are any special elements. Anyway, when I come across something like this when I’ve pasted a big blob of WordML..

Hi Jeni, I’ve having a bit of a problem and don’t know if its xsl or VS.Net. I’m running a transform in .NET 2.0 and basically processing all elements and if it is a ‘special’ element I do something but if it is a ‘word element’ I basically just try to replicate it, but I can’t use a xsl:copy-of because I need to process its sub elements to see if there are any special elements. Anyway, when I come across something like this when I’ve pasted a big blob of WordML..

<w:t> </w:t>

I am using basically templates like this:

<xsl:template match=”” mode=”replace-merge-fields”> <xsl:element name=”{name()}”> <xsl:apply-templates select=”@ | node()” mode=”replace-merge-fields”/> </xsl:element> </xsl:template>

<xsl:template match=”@*” mode=”replace-merge-fields”> <xsl:attribute name=”{name()}”><xsl:value-of select=”.”/></xsl:attribute> </xsl:template>

<xsl:template match=”text()” mode=”replace-merge-fields”> <xsl:choose> <xsl:when test=”.=’«DBACC»’”> <xsl:text>TerryAney:DBACC</xsl:text> </xsl:when> <xsl:otherwise><xsl:value-of select=”.”/></xsl:otherwise> </xsl:choose> </xsl:template>

The problem is for that <w:t> </w:t> that would have put a space between some words is now converted to <w:t /> and I lose the space. Is this something that is .NET specific or xsl specific?

Any suggestions on how to preserve the actual open and close element would be greatly appreciated.

Reply

The content of this field is kept private and will not be shown publicly.