如何在XSL中从XML获取CDATA值

时间:2014-05-12 12:16:33

标签: xslt

我需要使用XSLT转换XML的CDATA内的XML。

输入:

<pre>
  <![CDATA[<p><strong>Guidance</strong> about simplifying medication in <em>patients<em> with <a href="/formulary/en/drug-treatment-in-the-imminently-dying.html#heart-failure">end-stage CHF who appear to be imminently dying</a>.</p>]]>
</pre>

输出:

<ce:section-title>Pre</ce:section-title>
<ce:para><ce:bold>Guidance</ce:bold> about simplifying medication in <ce:italic>patients</ce:italic> with <ce:inter-ref xlink:type="simple" xlink:href="/formulary/en/drug-treatment-in-the-imminently-dying.html#heart-failure">end-stage CHF who appear to be imminently dying</ce:inter-ref>.</ce:para>

你能否就此提出建议。提前谢谢。

1 个答案:

答案 0 :(得分:2)

您可以使用哪个XSLT处理器和哪个版本的XSLT?使用Saxon 9的商业版本,您可以使用XSLT 3.0和

<xsl:template match="pre">
  <ce:section-title>Pre</ce:section-title>
  <xsl:apply-templates select="parse-xml(.)"/>
</xsl:template>

<xsl:template match="p">
  <ce:para>
    <xsl:apply-templates/>
  </ce:para>
</xsl:template>

<!-- now add similar templates here for transformation of strong, em etc -->