xslt を使用して、Mathml 入力から数式を出力したいと考えています。私の変換に間違いがあるに違いありません。修正方法がわかりません。私たちを手伝ってくれますか?パラメータまたは変数を使用して制御する必要がありますか? xml:
<?xml version="1.0" encoding="UTF-8"?>
<math>
<apply>
<eq/>
<apply>
<plus/>
<apply>
<power/>
<ci>x</ci>
<cn>2</cn>
</apply>
<apply>
<times/>
<cn>2</cn>
<ci>x</ci>
</apply>
<cn>2</cn>
</apply>
<cn>0</cn>
</apply>
</math>
これは私のxslです:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:apply-templates/>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="math">
<xsl:apply-templates select="apply"/>
</xsl:template>
<xsl:template match="apply">
<xsl:sequence select="name(element()[1]),'('"/>
<xsl:apply-templates select="apply">
</xsl:apply-templates>
<xsl:sequence select="element()[2],','"/>
<xsl:sequence select="element()[3],')',','"/>
</xsl:template>
</xsl:stylesheet>
結果は次のようになります。
eq(plus(power(x,2),times(2,x),2),0)