1

I am using the xslt 2.0 for the transformation. I want to transform the bellow line.

<ResultInfo><![CDATA[Concurrent processing error! <> & Test.]]></ResultInfo>

I am using the bellow transformation logic for this,

<xsl:template match="ResultInfo">
     <xsl:element name="ltc:{local-name()}">
          <xsl:value-of select="normalize-space(.)"/>
     </xsl:element>
</xsl:template>

when I run this logic I am getting the bellow output,

<ltc:ResultInfo>Concurrent processing error! <> & Test.</ltc:ResultInfo>

But I want to transfer as it is with the "CDATA". Please suggest me how can I preserve the "CDATA".

1 Answer 1

2

You can't "preserve" the CDATA, in the sense of using CDATA for output whenever it was used in the input, but you can request that the serializer use CDATA sections when outputting text node children of certain elements:

<xsl:output method="xml" cdata-section-elements="ltc:ResultInfo" />

This will serialize all ltc:ResultInfo elements using CDATA for their text content, regardless of whether the input used CDATA or plain text.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.