Avoiding a character in XSLT

I have an XSLT that converts XML to PLSQL

I need to escape the character:> (more)

Example:

P_C710_INT_PROFILE_ID =>

I tried using >and putting a character in xsl: text with no luck

Any ideas?

thank

+3
source share
3 answers

Thanks to everyone, but the correct answer is:

<xsl:text disable-output-escaping="yes">&gt;</xsl:text>
+5
source

No problems. This stylesheet (empty):

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
</xsl:stylesheet>

Input:

<text>P_C710_INT_PROFILE_ID =&gt;</text>

Conclusion:

P_C710_INT_PROFILE_ID =>

EDIT . Since your question is not clear, I am adding a solution if you want to output a character object under the declaration xsl: output / @ method = "text".

This style sheet:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text"/>
    <xsl:template match="text()" name="text">
        <xsl:param name="text" select="."/>
        <xsl:if test="$text != ''">
            <xsl:variable name="first" select="substring($text,1,1)"/>
            <xsl:choose>
                <xsl:when test="$first = '&gt;'">&amp;gt;</xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$first"/>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:call-template name="text">
                <xsl:with-param name="text" select="substring($text,2,(string-length($text)-1) div 2 + 1)"/>
            </xsl:call-template>
            <xsl:call-template name="text">
                <xsl:with-param name="text" select="substring($text,(string-length($text)-1) div 2 + 3)"/>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>

Conclusion:

P_C710_INT_PROFILE_ID =&gt;

This applies to Render escaped XML in the browser.

+3
source

disable-output-escaping, .

Then I looked in my source code, and I realized that I used XmlTextWriter with the conversion results, and XmlTextWriter applied output shielding. As soon as I switched it to just use StringWriter, the output was right.

+1
source

Source: https://habr.com/ru/post/1758214/


All Articles