xml 内のいくつかのノードを削除し、新しいノードを追加したいと考えています。次の xml で説明します。
<resprocessing>
<respcondition title="Correct" continue="No">
<conditionvar>
<varequal respident="Response_0">
<nhm_blank_name>Answer:</nhm_blank_name>
<nhm_numerator>14</nhm_numerator>
<nhm_denominator>25</nhm_denominator>
<nhm_allow_multiples>No</nhm_allow_multiples>
</varequal>
</conditionvar>
</respcondition>
</resprocessing>
<nhm_numerator>
ノードを削除し、他の 2 つのノードを保持したまま、その 下<nhm_denominator>
に新しい node( ) を挿入したい<nhm_blank_value>
<varequal>
<nhm_blank_name>
<nhm_allow_multiples>
新しいノードには次のような値があります。
<nhm_blank_value>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mfrac>
<mn>14</mn>
<mn>25</mn>
</mfrac>
</math>
</nhm_blank_value>
次の XSLT を使用して、前述のノードを正常に削除しました。しかし、新しいノードを追加できませんでした。どこが間違っているのか教えてください
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:param name="mathml">
<nhm_blank_value>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mfrac>
<mn>14</mn>
<mn>25</mn>
</mfrac>
</math>
</nhm_blank_value>
</xsl:param>
<!-- copy the xml as it is -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<!-- deleting nodes numerator and denominator -->
<xsl:template match="questestinterop/item/resprocessing/respcondition/conditionvar/varequal/nhm_denominator" />
<xsl:template match="questestinterop/item/resprocessing/respcondition/conditionvar/varequal/nhm_numerator" />
<!-- adding mathml node -->
<xsl:template match="questestinterop/item/resprocessing/respcondition/conditionvar">
<xsl:value-of select="varequal">
<xsl:with-param name="mathml"/>
</xsl:value-of>
</xsl:template>
</xsl:stylesheet>