xsl-list
[Top] [All Lists]

[xsl] disable-output-encoding with xsl:copy

2007-04-30 15:30:46
Hi all-

I am using Saxon 6.5.5 with XSLT version 1.1.

I'm currently working on a transformation which utilizes the identity template to perform a deep copy of all nodes in a set with the exception of one certain type of node ('graphic') and any of its descendants. These nodes are handled separately in their own template. The input and output is XML, with some HTML character codes contained within the text of the nodes being copied.

The structural bit copies just fine, with content and attributes showing up on the other side as well. The only issue I'm having is with certain HTML character codes (e.g. '“'). These seem to be getting encoded(decoded?) during the transformation. I want to preserve the character codes without specifying the xsl:output method as "html".

Below is the relevant template along with the input and output for a sample node:

<xsl:template mode="copy" match="@*|node()">
    <xsl:if test="not(ancestor::graphic)">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates mode="copy"/>
        </xsl:copy>
    </xsl:if>
</xsl:template>

input: <p>&#8220;You can&#8217;t always get what you want&#8230;&#8221;</p>

output: <p>“You can’t always get what you want…”</p>

I would like the text content of the output to exactly match the content of the input.

I have tried this alternate method but run into the same problem with the added effect of generating a ton of 'invalid element name' errors:
<xsl:template mode="copy" match="node()">
    <xsl:if test="not(ancestor::graphic)">
        <xsl:element name="name(.)" namespace="namespace-uri(.)">
            <xsl:copy-of select="@*"/>
<xsl:value-of select="text()" disable-output- escaping="yes"/>
            <xsl:apply-templates mode="copy"/>
        </xsl:element>
    </xsl:if>
</xsl:template>

Any help would be appreciated!
-Robert

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>