Hi,
 
I'm using a clean check out from Xalan CVS this morning but I've had this problem with much older versions as well.
 
With DOCTYPE in the mathml file, I never get the root math by match="/" but get #document instead.  And not one template will match.  I've got other xsl transforms that work fine and these don't have the DOCTYPE in them.  But I need the DOCTYPE for mathml so that all of the entities can be resolved.
 
I sent them as attachments rather then cut and paste into this email if anyone wants to run
 
java -ms64m -mx256m -Xbootclasspath/p:%XALAN_PATH%\build\xalan.jar;%XALAN_PATH%\xercesImpl.jar;%XALAN_PATH%\xml-apis.jar org.apache.xalan.xslt.Process -TS -TG -in wing-section.mml -xsl ./mathml2Java.xsl -out wing-section.java
 
on it and explain what I am doing wrong.  I'm puzzled by this and have tried many varitations on this.
 
Roger

Attachment: wing-section.mml
Description: Binary data

<?xml version="1.0"?>
<xsl:stylesheet  version="1.0" xmlns:math="http://www.w3.org/1998/Math/MathML"; xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:xlink="http://www.w3.org/1999/xlink"; xmlns:fo="http://www.w3.org/1999/XSL/Format";>
<!--xsl:stylesheet  version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:xlink="http://www.w3.org/1999/xlink"; xmlns:fo="http://www.w3.org/1999/XSL/Format"; xmlns:math="http://www.w3.org/TR/MathML2"-->
<!--xsl:import href="linearAlgebra.xsl"/>
<xsl:import href="statistics.xsl"/-->
  <xsl:output method="text" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="math" name="math">
    math<xsl:for-each select="*">
    <xsl:choose>
    <xsl:when test="name()='apply'">
    <xsl:call-template name="apply"/>
    </xsl:when>
    </xsl:choose>
    </xsl:for-each>
    <xsl:apply-templates/>
</xsl:template>

<xsl:template match="apply" name="apply">
  apply<xsl:for-each select="*">
  <xsl:choose>
  <xsl:when test="name()='eq'">
    <xsl:call-template name="eq"/>
  </xsl:when>
    </xsl:choose>
  </xsl:for-each>
  <!--xsl:if test="parent::*[name()='math']">
    <xsl:text>;
    </xsl:text>
  </xsl:if-->
</xsl:template>

<xsl:template match="/">
  <xsl:text>
public class Equation extends Object
{
    public Equation()
    {
    }
    
    public void crunch()
    {
</xsl:text><xsl:value-of select="name()"/>
  <!--xsl:for-each select="*"-->
    <!--xsl:call-template name="math"/-->
    <!--xsl:apply-templates/-->
  <!--/xsl:for-each-->
    <xsl:apply-templates />
  <xsl:text>
    }
    
    private double determinant(javax.vecmath.GMatrix A)
    {
        double det=0.0;
        double sign=1.0;
        for(int j=0;j&lt;A.getNumCol();j++)
        {
            int permutator=j;
            double value=0.0;
            for(int i=0;i&lt;A.getNumRow();i++)
            {
                value*=A.getElement(i, permutator++);
                if(permutator>=A.getNumCol())permutator=0;
            }
            det+=(sign*value);
            sign*=-1.0;
        }
    }
    
    private double magnitude(javax.vecmath.GVector V)
    {
        double magnitudeSquared=0.0;
        for(int i=0;i&lt;V.getSize();i++)
        {
        magnitudeSquared+=Math.pow(V.getElement(i), 2);
        }
        return Math.sqrt(magnitudeSquared);
    }
    
    private double mean(double[] array)
    {
        double sum=0.0;
        for(int i=0;i&lt;array.length;i++)
        {
        sum+=array[i];
        }
        return sum/array.length;
    }
    
    private double mean(long[] array)
    {
        double sum=0.0;
        for(int i=0;i&lt;array.length;i++)
        {
        sum+=array[i];
        }
        return sum/array.length;
    }
    
    private double mean(int[] array)
    {
        double sum=0.0;
        for(int i=0;i&lt;array.length;i++)
        {
        sum+=array[i];
        }
        return sum/array.length;
    }
    
    private double variance(double[] array)
    {
        double sum=0.0;
        double meanValue=mean(array);
        for(int i=0;i&lt;array.length;i++)
        {
        sum+=Math.pow(array[i]-meanValue, 2.0);
        }
        return sum/(array.length-1);
    }
    
    private double variance(long[] array)
    {
        double sum=0.0;
        double meanValue=mean(array);
        for(int i=0;i&lt;array.length;i++)
        {
        sum+=Math.pow(array[i]-meanValue, 2.0);
        }
        return sum/(array.length-1);
    }
    
    private double variance(int[] array)
    {
        double sum=0.0;
        double meanValue=mean(array);
        for(int i=0;i&lt;array.length;i++)
        {
        sum+=Math.pow(array[i]-meanValue, 2.0);
        }
        return sum/(array.length-1);
    }
    
    private double standardDeviation(double[] array)
    {
        return Math.sqrt(variance(array));
    }
    
    private double standardDeviation(long[] array)
    {
        return Math.sqrt(variance(array));
    }
    
    private double standardDeviation(int[] array)
    {
        return Math.sqrt(variance(array));
    }
    
    //Have this somewhere
    private double median(double[] array)
    {
        return 0.0;
    }
    
    private double median(long[] array)
    {
        return 0.0;
    }
    
    private double median(int[] array)
    {
        return 0.0;
    }
    
    //fill in
    private double mode(double[] array)
    {
        return 0.0;
    }
    
    private double mode(long[] array)
    {
        return 0.0;
    }
    
    private double mode(int[] array)
    {
        return 0.0;
    }
    
    //Think I know but need to check
    private double moment(double[] array, int p, int degree)
    {
        return 0.0;
    }
    
    private double moment(long[] array, int p, int degree)
    {
        return 0.0;
    }
    private double moment(int[] array, int p, int degree)
    {
        return 0.0;
    }
    
    private javax.vecmath.Matrix3d genericMatrix3d=null;
    private javax.vecmath.Matrix4d genericMatrix4d=null;
}
</xsl:text>
</xsl:template>

<xsl:template match="mrow">
  <!--xsl:for-each select="./*"-->
   <!--xsl:value-of select="name()"/-->
    <xsl:apply-templates select="./*"/>
  <!--/xsl:for-each-->
  <xsl:if test="parent::*[name()='math']">
    <xsl:text>;
    </xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="semantics">
    <xsl:apply-templates select="./*"/>
  <xsl:if test="parent::*[name()='math']">
    <xsl:text>;
    </xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="annotation-xml">
</xsl:template>

<xsl:template match="plus" name="plus">
  <xsl:text>(</xsl:text>
  <xsl:for-each select="parent::apply/*[position()>1]">
    <xsl:if test="not(position()=1)">
      <xsl:text>+</xsl:text>
    </xsl:if>
  <xsl:if test="local-name()='ci'">
    <xsl:value-of select="."/>
   </xsl:if>
  <xsl:if test="local-name()='apply'">
    <xsl:call-template name="apply"/>
  </xsl:if>
  </xsl:for-each>
  <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="times" name="times">
  <xsl:text>(</xsl:text>
  <xsl:for-each select="parent::apply/*[position()>1]">
  <xsl:if test="not(position()=1)">
    <xsl:text>*</xsl:text>
  </xsl:if>
  <xsl:if test="not(local-name()='apply')">
    <xsl:value-of select="."/>
   </xsl:if>
  <xsl:if test="local-name()='apply'">
    <xsl:apply-templates/>
  </xsl:if>
  </xsl:for-each>
      <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="divide" name="divide">
  <!--xsl:text>(</xsl:text>
  <xsl:for-each select="./*">
  <xsl:if test="not(position()=1)">
    <xsl:text>/</xsl:text>
  </xsl:if>
  <xsl:if test="not(local-name()='apply')">
    <xsl:value-of select="."/>
   </xsl:if>
  <xsl:if test="local-name()='apply'">
    <xsl:apply-templates/>
  </xsl:if>
  </xsl:for-each>
      <xsl:text>)</xsl:text-->
    <xsl:apply-templates select="ancestor::apply/*[2]"/>
     <xsl:text>/</xsl:text>
    <xsl:apply-templates select="ancestor::apply/*[3]"/>
</xsl:template>

<xsl:template match="msup|power">
  <xsl:text>Math.pow(</xsl:text>
  <xsl:for-each select="./*">
    <xsl:value-of select="." disable-output-escaping = "yes"/>
    <xsl:if test="not(position()>1)">
      <xsl:text>, </xsl:text>
    </xsl:if>
  </xsl:for-each>
  <xsl:text>)</xsl:text>
</xsl:template>

<!--xsl:template match="msubsup/mo[position()=1 and text()='&#x0222B;'] /msubsup/mn[position()=1] /msubsup/mi[position()=1]"-->
<xsl:template match="msubsup[position()=1] /child::mo[position()=1 and text()='&#x0222B;']">
  <xsl:variable name="lower-limit" select="../child::*[2]"/>
  <xsl:variable name="upper-limit" select="../child::*[3]"/>
  <xsl:variable name="differential" select="../following-sibling::* //*[text()='&#x02146;'] /following-sibling::*"/>
  <!--xsl:text>We're here.
  </xsl:text-->
    <!--xsl:value-of select="$lower-limit" disable-output-escaping = "yes"/>
    <xsl:value-of select="$upper-limit" disable-output-escaping = "yes"/>
    <xsl:value-of select="$differential" disable-output-escaping = "yes"/-->
    <xsl:if test="../following-sibling::mfrac /child::mrow /following-sibling::mi[text()=$differential]">
      <xsl:text>Math.log(</xsl:text>
      <xsl:value-of select="$upper-limit" disable-output-escaping = "yes"/>
      <xsl:text>)-Math.log(</xsl:text>
      <xsl:value-of select="$lower-limit" disable-output-escaping = "yes"/>
      <xsl:text>)
      </xsl:text>
    </xsl:if>
  <!--xsl:call-template name="log-integral"/-->
  <!--xsl:for-each select="../following-sibling::mfrac /child::mrow /following-sibling::mi[text()=$differential]">
      <xsl:value-of select="name()" disable-output-escaping = "yes"/>
      <xsl:text>, </xsl:text>
      <xsl:text> and here
      </xsl:text>
  </xsl:for-each-->
</xsl:template>

<xsl:template match="mfrac" name="log-integral">
      <xsl:text> log-integral
      </xsl:text>
  <xsl:for-each select="./*">
    <!--xsl:if test="position()=1"-->
      <xsl:value-of select="name()" disable-output-escaping = "yes"/>
      <xsl:text>, </xsl:text>
    <!--/xsl:if-->
      <xsl:text> and here
      </xsl:text>
  </xsl:for-each>
</xsl:template>

<xsl:template match="msqrt|mroot">
  <xsl:text>Math.sqrt(</xsl:text>
  <xsl:for-each select="./*">
    <xsl:value-of select="." disable-output-escaping = "yes"/>
    <xsl:if test="not(position()>1)">
      <xsl:text>, </xsl:text>
    </xsl:if>
  </xsl:for-each>
  <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="mfrac">
  <xsl:text>(</xsl:text>
  <xsl:for-each select="./child::*">
    <xsl:value-of select="." disable-output-escaping = "yes"/>
    <xsl:if test="not(position()>1)">
      <xsl:text>/</xsl:text>
    </xsl:if>
  </xsl:for-each>
  <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="mo">
  <xsl:choose>
   <xsl:when test="text()='&#x02062;'">
     <xsl:text>*</xsl:text>
   </xsl:when>
   <xsl:when test="text()='+'">
     <xsl:text>+</xsl:text>
   </xsl:when>
   <xsl:otherwise>
     <xsl:value-of select="text()" disable-output-escaping = "yes"/>
      <!--xsl:apply-templates select="@*"/-->
   </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="eq" name="eq">
    <xsl:apply-templates select="parent::apply/*[2]"/>
     <xsl:text>=</xsl:text>
    <xsl:apply-templates select="parent::apply/*[3]"/>
</xsl:template>

<xsl:template match="ci" name="ci">
     <xsl:value-of select="."/>ci
</xsl:template>

<xsl:template match="pi">
     <xsl:text>Math.PI</xsl:text>
</xsl:template>

<xsl:template match="exp">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.exp(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="ln">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.log(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="log">
  <xsl:variable name="variable" select="parent::apply/*[3]"/>
  <xsl:variable name="base" select="parent::apply/*[2]"/>
     <xsl:text>Math.log(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)/Math.log(</xsl:text><xsl:value-of select="$base"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="sin">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.sin(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="cos">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.cos(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="tan">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.tan(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="sec">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.sec(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="csc">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.csc(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="cot">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.cot(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="sinh">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.sinh(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="cosh">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.cosh(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="tanh">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.tanh(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="sech">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.sech(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="csch">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.csch(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="coth">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.coth(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="arcsin">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.asin(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="arccos">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.acos(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="atan">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.atan(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="arccosh">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.arccosh(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="arccot">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.arccot(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="arccoth">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.arccoth(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="arccsc">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.arccsc(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="arccsch">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.arccsch(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="arcsec">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.arcsec(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="arcsech">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.arcsech(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="arcsinh">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.arcsinh(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="arctanh">
  <xsl:variable name="variable" select="parent::apply/*[2]"/>
     <xsl:text>Math.arctanh(</xsl:text><xsl:value-of select="$variable"/>
     <xsl:text>)</xsl:text>
</xsl:template>

</xsl:stylesheet>

Reply via email to