Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well outputting an element's content as a CDATA section is easy with the <code>cdata-section-elements</code> attribute on <code>xsl:output</code> but you also seem to want to serialize the nodes inside the <code>requestXml</code> element in the input XML to form the contents of the CDATA section. To serialize you either need to check whether your XSLT processor supports an extension doing that or you need to use an XSLT 1.0 stylesheet doing that, such as provided on <a href="http://lenzconsulting.com/xml-to-string/" rel="nofollow">http://lenzconsulting.com/xml-to-string/</a>.</p> <p>You can then import that stylesheet and use it as follows:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:import href="xml-to-string.xsl"/&gt; &lt;xsl:output method="xml" cdata-section-elements="requestXml"/&gt; &lt;xsl:template match="/"&gt; &lt;xsl:apply-templates/&gt; &lt;/xsl:template&gt; &lt;xsl:template match="@* | node()"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@* | node()"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="requestXml"&gt; &lt;xsl:copy&gt; &lt;xsl:call-template name="xml-to-string"&gt; &lt;xsl:with-param name="node-set" select="node()"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>That way the input</p> <pre><code>&lt;Create&gt; &lt;requestXml&gt; &lt;ISD_XMLGateway&gt; &lt;Entity&gt;HLR_ALC&lt;/Entity&gt; &lt;Origin&gt;Comverse One&lt;/Origin&gt; &lt;Log_Level&gt;0&lt;/Log_Level&gt; &lt;Params&gt; &lt;Param Name="HLR_System" Value="JT"/&gt; &lt;Param Name="HLR_ALC_Command" Value="Send_HLR_Command"/&gt; &lt;Param Name="HLR_Command" Value="CRESBX:MSIN=Start43515213,MODEL=MODEL002,SNBSV=7797098765-TEL;"/&gt; &lt;/Params&gt; &lt;/ISD_XMLGateway&gt; &lt;/requestXml&gt; &lt;/Create&gt; </code></pre> <p>is transformed into the result</p> <pre><code>&lt;Create&gt; &lt;requestXml&gt;&lt;![CDATA[ &lt;ISD_XMLGateway&gt; &lt;Entity&gt;HLR_ALC&lt;/Entity&gt; &lt;Origin&gt;Comverse One&lt;/Origin&gt; &lt;Log_Level&gt;0&lt;/Log_Level&gt; &lt;Params&gt; &lt;Param Name="HLR_System" Value="JT"/&gt; &lt;Param Name="HLR_ALC_Command" Value="Send_HLR_Command"/&gt; &lt;Param Name="HLR_Command" Value="CRESBX:MSIN=Start43515213,MODEL=MODEL002,SNBSV=7797098765-TEL;"/&gt; &lt;/Params&gt; &lt;/ISD_XMLGateway&gt; ]]&gt;&lt;/requestXml&gt; &lt;/Create&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload