[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: What is the simplest method for using xsl:sort wi

Subject: Re: What is the simplest method for using xsl:sort without losing attribute names and values?
From: "Mark Wilson" <mark@xxxxxxxxxxxx>
Date: Sun, 20 Jul 2008 10:58:23 -0700
Re:  What is the simplest method for using xsl:sort  wi
Hello Martin,

After I was told you had answered, I found your email in the junk. Sorry I missed it the first time.

I am reconstructing the original sequence of journal articles from a <List> of non-sequential <Items>. My task is to sort the several hundred <Items>in a <List> container by Year, Issue Number, and Page.

In the example below, only one <Item> is shown. I tried the template you suggested. As before, in the output I get a concatenation of the attribute values in the tags that have attributes. See <Cat> and <Person> illustrated as input and output below:

Thanks,
Mark

You suggested:
<xsl:template match="*">
       <xsl:copy>
           <xsl:apply-templates select="@*"/>
           <xsl:apply-templates>
               <xsl:sort select="Article/Year" />
               <xsl:sort select="Article/IssueNumber"/>
               <xsl:sort select="Article/Page" />
           </xsl:apply-templates>
       </xsl:copy>
   </xsl:template>

My input:
<List>
<Item>
       <Cat pofis="4" pofis-number="116"/>
       <Subject>Errors</Subject>
       <Subject>Color Errors</Subject>
       <Subject>Olympic Games. Atlanta</Subject>
       <Article>
           <Person>Fritz, Zdenek</Person>
           <Person is-author="false">Kleskovic, Peter Z.</Person>
           <Title>Imperfect color se-tenant</Title>
           <Year>2000</Year>
           <IssueNumber>1</IssueNumber>
           <IssueName>Jan/Feb</IssueName>
           <Page>10</Page>
       </Article>
   </Item>
</List>

The output from your template:
<List>
<Item>
       <Cat>4116</Cat>
       <Subject>Errors</Subject>
       <Subject>Color Errors</Subject>
       <Subject>Olympic Games. Atlanta</Subject>
       <Article>
           <Person>Fritz, Zdenek</Person>
           <Person>falseKleskovic, Peter Z.</Person>
           <Title>Imperfect color se-tenant</Title>
           <Year>2000</Year>
           <IssueNumber>1</IssueNumber>
           <IssueName>Jan/Feb</IssueName>
           <Page>10</Page>
       </Article>
   </Item>
</List>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.