开发者

How to transform superscript/subscript in XML to HTML

I have the following XML snippet with formulas as part of some other text. This is being transformed to HTML by 开发者_开发百科an XSLT. The final HTML output should reflect the superscript applied. What is the right approach to achieve this?

The XML snippet is generated as below

<meta name="Abstract" content="We present different models used in nuclear astrophysics. In particular the role of microscopic cluster theories is emphasized. Recent applications on the triple-&amp;#945; process, and on the &lt;sup&gt;12&lt;/sup&gt;C(&amp;#945;, &amp;#947;)&lt;sup&gt;16&lt;/sup&gt;O and &lt;sup&gt;3&lt;/sup&gt;He(&amp;#945;, &amp;#947; )&lt;sup&gt;7&lt;/sup&gt;Be reactions are discussed. (author)"/>

Currently, when I apply the XSLT, the output is as below

We present different models used in nuclear astrophysics. In particular the role of microscopic cluster theories is emphasized. Recent applications on the triple-&#945; process, and on the <sup>12</sup>C(&#945;, &#947;)<sup>16</sup>O and <sup>3</sup>He(&#945;, &#947; )<sup>7</sup>Be reactions are discussed. (author)

Any help appreciated.


The problem is that whoever generated this put markup inside an attribute. This effectively destroys all markup and the result is just a 1-dimensional text inside the attribute.

This is an evil practice, indeed. To be able to process the string as markup -- using XPath and XSLT -- the markup needs to be re-constituted from the string. You need to have either a pre-processing step to parse the content of the content attribute as a new XmlDocument, or you could call an extension function (that you need to write) within the XSLT code, that would parse the text and return a document node.

In XSLT 3.0 / XPath 3.0 there will be a standard function parse-xml() exactly for cases like this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜