不需要 DOE(而且它的使用不仅仅是不好的味道!):
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="my:my">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<my:fractions>
<frac14>¼</frac14>
<frac12>½</frac12>
<frac34>¾</frac34>
<frac18>⅛</frac18>
<frac38>⅜</frac38>
<frac58>⅝</frac58>
<frac78>⅞</frac78>
</my:fractions>
<xsl:variable name="vFracs" select="document('')/*/my:fractions/*"/>
<xsl:template match="fraction">
<xsl:value-of select="$vFracs[name()= concat('frac', current()/@n, current()/@d)]"/>
</xsl:template>
</xsl:stylesheet>
当此转换应用于提供的 XML 文档时:
<fraction d="2" n="1"/>
产生了想要的正确结果:
½