Re: [xsl] How does one convert an RTF to a string?

Subject: Re: [xsl] How does one convert an RTF to a string?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 9 Jun 2005 21:59:59 +0100
>     Why am I not getting the whitepsaces in my RTF or the comments?

comments within a stylesheet are ignored, always.
White space is ignored by default but you can cause it not to be ignored
within your element definition. by using xml:space="preserve" or
xsl:preserve-space 


Note if you do get a comment node (eg if your real case is nodes copied
from some source) then you wouldn't want


        <xsl:template match="comment()" mode="convert">
                <xsl:comment><xsl:value-of select="." /></xsl:comment>
        </xsl:template>

you'd want


        <xsl:template match="comment()" mode="convert">
 <xsl:text>&lt;!--</xsl:text>
<xsl:value-of select="." />
 <xsl:text>--&gt;</xsl:text>
        </xsl:template>

If your real case is a fixed variable in teh stylesheet you don't want
to this at all, you just want to define the variable to have the string
not the nodes in teh first place


                <xsl:variable name="rtf"><![CDATA[
                                <node>
                                        <!-- Here is a comment -->

                                        <child attrib="something" >value</child>
                                </node>
                </xsl:variable>

                <xsl:variable name="tmpStr">
                <xsl:apply-templates select="xalan:nodeset($rtf)"
mode="convert" />
                ]]></xsl:variable>

                <xsl:value-of select="rtf" />


I note in your example you used disable-output-escaping use of that is
always always a sign that somethng is wrong. Here it looks very odd
You disable the normal XML serialisation by using value-of and d-o-e
which means thatyou have to serialise everything by hand.

Why not just let the system use its normal XML serialisation, by just
copying the original rtf  variable to the result tree???




                <xsl:variable name="rtf">
                                <node>
                                        <!-- Here is a comment -->

                                        <child attrib="something" >value</child>
                                </node>
                </xsl:variable>

                <xsl:variable name="tmpStr">
                <xsl:apply-templates select="xalan:nodeset($rtf)"
mode="convert" />
               </xsl:variable>

                <xsl:copy-of select="rtf" />

________________________________________________________________________
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