[xsl] How to I keep attributes names and values in a sort?

Subject: [xsl] How to I keep attributes names and values in a sort?
From: "Mark Wilson" <mark@xxxxxxxxxxxx>
Date: Sun, 20 Jul 2008 08:41:30 -0700
Newby, using [so-to-speak] XSLT 2.0, Saxon, Oxygen, on Windows Vista. When I do a sort, I lose the attribute names and values unless I include a specific template matching elements that have attributes (see listing 2). When I use the styles sheet in listing 1, I get the concatenated value of the attributes within the start tag, but not the attribute names as in <Cat 135> instead of <Cat pofis="1" pofis-number="35">. Is there a simpler design than Listing 2?

Listing 1.
<xsl:template match="*">
       <xsl:copy>
           <xsl:apply-templates>
               <xsl:sort select="Article/Year" />
              <xsl:sort select="Article/IssueNumber" data-type="number" />
               <xsl:sort select="Article/Page" data-type="number" />
           </xsl:apply-templates>
       </xsl:copy>
   </xsl:template>

Listing 2.
<xsl:template match="*">
       <xsl:copy>
           <xsl:apply-templates>
               <xsl:sort select="Article/Year" />
              <xsl:sort select="Article/IssueNumber" data-type="number" />
               <xsl:sort select="Article/Page" data-type="number" />
           </xsl:apply-templates>
       </xsl:copy>
   </xsl:template>

<xsl:template match="Person">
<xsl:element name="Person">
<xsl:if test="@is-author">
<xsl:attribute name="is-author">
<xsl:value-of select="@is-author" />
</xsl:attribute>
</xsl:if>
<xsl:value-of select="."></xsl:value-of>
</xsl:element>
</xsl:template>


Current Thread