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-&#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)"/>
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-α process, and on the <sup>12</sup>C(α, γ)<sup>16</sup>O and <sup>3</sup>He(α, γ )<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.
精彩评论