Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


sorting nodes

From: "tshad" <tshad@----------.--->
To: NULL
Date: 4/3/2008 4:25:00 PM

I can't seem to get my results to be formatted.

I have the following xml:

<?xml version="1.0" encoding="utf-8"?>
<Report>
 <data>
   <form name="order" primary="false">
  <tag name="DUEDATE" flags="1" format="4096">12/01/2007</tag>
   </form>
   <form name="title" primary="false">
  <tag name="CITY_STATE_ZIP.1" flags="0" format="12288">Surprise, AZ 
85374-2525</tag>
   </form>
   <form name="1004_05" primary="true">
  <section type="options" number="0">
    <tag name="OPT_TYPE_OF_APPRAISAL.1" flags="1" format="12288">Summary 
Appraisal Report</tag>
  </section>
  <section type="subject" number="0">
    <tag name="CITY.1" flags="0" format="0">Surprise</tag>
  </section>
  <section type="salescomp" number="1">
    <tag name="GS_AGE.1" flags="0" format="0">9 Yrs.</tag>
  </section>
  <section type="salescomp" number="2">
    <tag name="GS_AGE.1" flags="0" format="0">12 Yrs.</tag>
  </section>
   </form>
 </data>
</Report>

I also have the following xslt file:

<xsl:stylesheet version="1.0"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
exclude-result-prefixes="xsi">
 <xsl:output method="xml" indent="yes"/>
 <xsl:template match="/*">
  <xsl:copy>
   <xsl:apply-templates select="data/form/tag | data/form/section/tag">
    <xsl:sort select="form/@primary" order="ascending"/>
   </xsl:apply-templates>/>
  </xsl:copy>
 </xsl:template>
 <xsl:template match="tag">
  <form>
   <sectionNumber>
    <xsl:value-of select="ancestor::section/@number"/>
   </sectionNumber>
   <primary>
    <xsl:value-of select="ancestor::form/@primary"/>
   </primary>
   <formName>
    <xsl:value-of select="ancestor::form/@name"/>
   </formName>
   <tagName>
    <xsl:value-of select="@name"/>
   </tagName>
   <flags>
    <xsl:if test="not(@flags)">
     <xsl:attribute name="xsi:nil">true</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="@flags"/>
   </flags>
   <format>
    <xsl:if test="not(@format)">
     <xsl:attribute name="xsi:nil">true</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="@format"/>
   </format>
   <value>
    <xsl:value-of select="."/>
   </value>
  </form>
 </xsl:template>
</xsl:stylesheet>

My sort doesn't seem to work.  Regardless, whether I use ascending or 
descending, I get:

<?xml version="1.0" encoding="utf-8"?>
<Report>
 <data>
   <form name="order" primary="false">
  <tag name="DUEDATE" flags="1" format="4096">12/01/2007</tag>
   </form>
   <form name="title" primary="false">
  <tag name="CITY_STATE_ZIP.1" flags="0" format="12288">Surprise, AZ 
85374-2525</tag>
   </form>
   <form name="1004_05" primary="true">
  <section type="options" number="0">
    <tag name="OPT_TYPE_OF_APPRAISAL.1" flags="1" format="12288">Summary 
Appraisal Report</tag>
  </section>
  <section type="subject" number="0">
    <tag name="CITY.1" flags="0" format="0">Surprise</tag>
  </section>
  <section type="salescomp" number="1">
    <tag name="GS_AGE.1" flags="0" format="0">9 Yrs.</tag>
  </section>
  <section type="salescomp" number="2">
    <tag name="GS_AGE.1" flags="0" format="0">12 Yrs.</tag>
  </section>
   </form>
 </data>
</Report>

It is in the order of the original file.  Why is that?

Thanks,

Tom 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent