This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sort problem


On Wednesday 04 September 2002 21:28, aruniima.chakrabarti@iflexsolutions.com 
wrote:
>  Thanks David... but i still confused...if i do <xsl:apply-templates
> select="@* | * | text()"> or <xsl:apply-templates select="@* | * |
> node()">, the output doesnot contain any of the attributes. Please help in
> getting the required output.

The problem is probably that if you output attributes, they must be output 
immediately after the element to which they belong (you can't output any 
other elements or text before your attributes).

Since you are sorting by the name() of the nodes, the text() nodes will always 
be output first, since the name of a text node is "#text".  The hash mark (#) 
will be sorted alphabetically before the names of your attributes.

The solution could be to apply-templates to attributes and other nodes 
separately.  It doesn't make any sense to sort the output of attributes 
anyway (since attributes don't have any defined order).

<xsl:template match="/ | @* | node()">
  <xsl:copy>
    <xsl:apply-templates select="@*"/>
    <xsl:apply-templates select="node()">
      <xsl:sort select="name()"/>
    </xsl:apply-templates>
  </xsl:copy>
</xsl:template>

Let me know if this solves your problem, and HTH.

-- 
Peter Davis

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]