vendredi 31 juillet 2015

Subtractions and Divisions are giving me NaN | XSLT & XML

So, I'm trying to make a symbolic derivative calculator and it works with a single hitch. It gives me NaN with this XML

    <?xml version="1.0"?>
<sum>
    <mono>  
        <arg>3</arg>
        <var>x</var>
        <exp>2</exp>
    </mono>
</sum>

And this stylesheet that gives the numbers the behaviour they should have in a derivative.

    <xsl:stylesheet version="1.0"        xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match = "/">
    <mono>
        <arg>
            <xsl:value-of select="arg div exp"></xsl:value-of>
        </arg>
    <var>
        <xsl:if test="exp > 0"/>
        X
    </var>
    <exp>
        <xsl:value-of select="exp - 1"></xsl:value-of>
    </exp>
</mono>
</xsl:template>
</xsl:stylesheet>

Aucun commentaire:

Enregistrer un commentaire