You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Cory Isaacson <ci...@compuflex.com> on 2002/11/01 06:57:16 UTC

Sort problem

I have two sort documents, and in one version I sort numbers (which works
fine), and in the other I am sorting a text value. They are the same, with
the exception of the data-type attribute not being included in the text one.
This same code used to work in earlier version of Xalan (we are using XalanJ
2.4.D1.

Any ideas what is wrong? Is this a bug?

Thanks,

Cory

-- Numeric sort that works:

  <!-- Output the fw:dataSetData element.-->
  <xsl:template match="/">
    <fw:dataSetData>
    <xsl:apply-templates select="/fw:dataSet/fw:dataSetData"/>
    </fw:dataSetData>
  </xsl:template>

  <!-- Loop each row and sort.-->
  <xsl:template match="fw:dataSet/fw:dataSetData">
    <xsl:for-each select="./fw:row">
      <!-- Place sort elements here.-->
      <xsl:sort order="ascending" data-type="number"
select="././fw:column[@index='1']" />


        <!-- Copy each row.-->
        <xsl:copy>
          <xsl:apply-templates select="@*|*|text()"/>
        </xsl:copy>

    </xsl:for-each>
  </xsl:template>

  <xsl:template match=".|@*|*|text()">
     <xsl:copy>
        <xsl:apply-templates  select="@*|*|text()"/>
     </xsl:copy>
  </xsl:template>

-- Text sort which does not work:

  <!-- Output the fw:dataSetData element.-->
  <xsl:template match="/">
    <fw:dataSetData>
    <xsl:apply-templates select="/fw:dataSet/fw:dataSetData"/>
    </fw:dataSetData>
  </xsl:template>

  <!-- Loop each row and sort.-->
  <xsl:template match="fw:dataSet/fw:dataSetData">
    <xsl:for-each select="./fw:row">
      <!-- Place sort elements here.-->
      <xsl:sort order="ascending" select="././fw:column[@index='2']" />


        <!-- Copy each row.-->
        <xsl:copy>
          <xsl:apply-templates select="@*|*|text()"/>
        </xsl:copy>

    </xsl:for-each>
  </xsl:template>

  <xsl:template match=".|@*|*|text()">
     <xsl:copy>
        <xsl:apply-templates  select="@*|*|text()"/>
     </xsl:copy>
  </xsl:template>




Cory Isaacson
President & CTO
Compuflex International
(818) 884-1168
cisaacson@compuflex.com
www.compuflex.com


RE: Sort problem

Posted by Cory Isaacson <ci...@compuflex.com>.
This is solved now. It was a data error in my XML doc.

Thanks,

Cory
  -----Original Message-----
  From: Cory Isaacson [mailto:cisaacson@compuflex.com]
  Sent: Thursday, October 31, 2002 9:57 PM
  To: xalan-dev@xml. apache. org
  Subject: Sort problem


  I have two sort documents, and in one version I sort numbers (which works
fine), and in the other I am sorting a text value. They are the same, with
the exception of the data-type attribute not being included in the text one.
This same code used to work in earlier version of Xalan (we are using XalanJ
2.4.D1.

  Any ideas what is wrong? Is this a bug?

  Thanks,

  Cory

  -- Numeric sort that works:

    <!-- Output the fw:dataSetData element.-->
    <xsl:template match="/">
      <fw:dataSetData>
      <xsl:apply-templates select="/fw:dataSet/fw:dataSetData"/>
      </fw:dataSetData>
    </xsl:template>

    <!-- Loop each row and sort.-->
    <xsl:template match="fw:dataSet/fw:dataSetData">
      <xsl:for-each select="./fw:row">
        <!-- Place sort elements here.-->
        <xsl:sort order="ascending" data-type="number"
select="././fw:column[@index='1']" />


          <!-- Copy each row.-->
          <xsl:copy>
            <xsl:apply-templates select="@*|*|text()"/>
          </xsl:copy>

      </xsl:for-each>
    </xsl:template>

    <xsl:template match=".|@*|*|text()">
       <xsl:copy>
          <xsl:apply-templates  select="@*|*|text()"/>
       </xsl:copy>
    </xsl:template>

  -- Text sort which does not work:

    <!-- Output the fw:dataSetData element.-->
    <xsl:template match="/">
      <fw:dataSetData>
      <xsl:apply-templates select="/fw:dataSet/fw:dataSetData"/>
      </fw:dataSetData>
    </xsl:template>

    <!-- Loop each row and sort.-->
    <xsl:template match="fw:dataSet/fw:dataSetData">
      <xsl:for-each select="./fw:row">
        <!-- Place sort elements here.-->
        <xsl:sort order="ascending" select="././fw:column[@index='2']" />


          <!-- Copy each row.-->
          <xsl:copy>
            <xsl:apply-templates select="@*|*|text()"/>
          </xsl:copy>

      </xsl:for-each>
    </xsl:template>

    <xsl:template match=".|@*|*|text()">
       <xsl:copy>
          <xsl:apply-templates  select="@*|*|text()"/>
       </xsl:copy>
    </xsl:template>




  Cory Isaacson
  President & CTO
  Compuflex International
  (818) 884-1168
  cisaacson@compuflex.com
  www.compuflex.com