문제

I need to transform the XML inside the CDATA of the XML using the XSLT.

Input:

<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>

Output:

<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>

Could you please suggest me on this. Thanks in advance.

도움이 되었습니까?

해결책

Which XSLT processor and which version of XSLT can you use? With the commercial versions of Saxon 9 you can use XSLT 3.0 and

<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 -->
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top