I have an XML file structured like this:
<Chem>
<Formula>
CO{2}
</Formula>
<Name>
Carbon Dioxide
</Name>
</Chem>
How would I use XSLT to format the number (or all numbers in curly brackets) to subscript?
I have an XML file structured like this:
<Chem>
<Formula>
CO{2}
</Formula>
<Name>
Carbon Dioxide
</Name>
</Chem>
How would I use XSLT to format the number (or all numbers in curly brackets) to subscript?
Copyright © 2021 Jogjafile Inc.
In XSLT 2.0 or higher, you could convert all digit characters within curly braces to subscript using:
Note the double escaping of the curly brace characters: first, they are doubled to distinguish them from AVT expressions in XSLT; next, they are preceded by
\to be interpreted as literal characters in regex.The result using your example input: