public
Created

XSLT to convert http://www.w3.org/Math/characters/unicode.xml into Python Dictionary

  • Download Gist
unicode_to_latex.xslt
XSLT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<xsl:template match="/charlist">
<xsl:text>
unicode_to_latex = {
</xsl:text>
<xsl:for-each select="character">
<xsl:variable name="codepoint" select="./@id"/>
<xsl:if test="string-length(latex)&gt;1">
<xsl:text> u"\u</xsl:text><xsl:value-of select="substring($codepoint, 3)" /><xsl:text>": "</xsl:text><xsl:value-of select="replace(replace(latex, '\\', '\\\\'), '&quot;', '\\&quot;')"/><xsl:text>",
</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>}
</xsl:text>
</xsl:template>
</xsl:stylesheet>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.