How do I force xslt transformation to load data into cdata sections?

后端 未结 2 745
心在旅途
心在旅途 2021-01-20 10:54

I have a client who requires all text in the xml I supply them with to be in CDATA sections. I understand that text should not need to be in CDATA as it has already been par

2条回答
  •  萌比男神i
    2021-01-20 11:34

    Well as your question title talks about XSLT and your question is flagged as XSLT, the XSLT way to ensure a result element's content is serialized as a CDATA section is to use the cdata-section-elements attribute on the xsl:output element (http://www.w3.org/TR/xslt20/#serialization) listing all elements you want to output as CDATA sections. Thus if you know the elements you want to output as CDATA sections when writing the stylesheet it is a simple as listing them in that attribute. Does that help? Or do you want to postprocess arbitrary XML with XSLT to add CDATA sections?

提交回复
热议问题