xml - Transforming XSLT text element with "one space character" yields empty content -


i've got incoming xml i'm transforming (with xslt in asp using msxsm6):

<cell>     <data xmlns="http://www.w3.org/tr/rec-html40">       <font>text1</font>       <font> </font>       <font>text2</font>     <data>   </cell> 

if template <font> is:

<xsl:template match="font">   <xsl:copy/> </xsl:template> 

the transform seems kill off space character in 2nd element in source, output xml emitted below, 2nd element becomes empty 1 no content:

    <font>text1</font>       <font/>       <font>text2</font>   

i trialed-and-errored on <xsl:preserve-space elements="font"/>' didn't seem help. ideas? stackoverflow!

first, stylesheet fragment sample wrong. need rule this:

<xsl:template match="html:data//node()|html:data//*/@*"               xmlns:html="http://www.w3.org/tr/rec-html40">    <xsl:copy>      <xsl:apply-templates select="node()|@*">    </xsl:copy>  </xsl:template> 

second, input white space text nodes. preserve depending on xml tree provider. msxsl doesn't preserve default. solution add xml:space="preserve" attribute in input source.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -