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

Sorting Problem

Subject: Sorting Problem
From: walter.crockett@xxxxxxxxxxxxxxxxxxxxx
Date: Mon, 14 Apr 2003 13:48:30 -0400
valuelist sorting
Hello. My XML file is full of Object constructions such as the following
(simplified). The first Object is a Job that has multiple Runs. The second
object is one of the Runs referenced by the Job. I need to find all the runs
for the particular job, and then sort the runs by their
/Attributes[Name='Started at']/Value. (In other words, I want to sort the
Runs by the time they started.)

<Object id="PID-1">
 <SubAttributes CreationType="Job" Name="Job1"/>
 <Attributes>
  <Name>Name</Name>
  <Value>Job1</Value>
 </Attributes>
 <Relationships>
  <Relationship>
   <Name>Has_Run</Name>
   <ValueList>
    <Value>
     <Reference Id="#PID-2">Run 1</Reference>
    </Value>
    <Value>
     <Reference Id="#PID-3">Run 2</Reference>
    </Value>
   </ValueList>
  </Relationship>
 </Relationships>
</Object>

<Object id="PID-2">
 <SubAttributes CreationType="Run" Name="Run1"/>
 <Attributes>
  <Name>Started at</Name>
  <Value>2003-04-07 11:32:37</Value>
 </Attributes>
 <Relationships>
  <Relationship>
   <Name>Of_Job</Name>
   <ValueList>
    <Value>
     <Reference Id="#PID-1">Job1</Reference>
    </Value>
   </ValueList>
  </Relationship>
  <Relationship>
   <Name>Has_Component_Run</Name>
   <ValueList>
    <Value>
     <Reference Id="#PID-4">Component_Run 1</Reference>
    </Value>
   </ValueList>
  </Relationship>
 </Relationships>			
</Object>

Normally, I would start with:
<xsl:for-each
select="//Object[@id=$JobID]/Relationships/Relationship[Name='Has_Run']/Valu
eList/Value/Reference/@Id">

Then I would hope to sort the Runs by their "Started at" value. But I can
find no way to do such a sort in this order. You can't just put each Run Id
into a variable (after removing the hash mark) and then sort. For example,
creating a variable after the xsl:for-each and then doing this doesn't work
at all:
 <xsl:sort select="//Object[@id=$RunID]/Attributes[Name='Started
at']/Value." order="descending"/>

So I have been reduced to starting with all Runs, regardless of which Job
they come from:
<xsl:for-each
select="//Object/SubAttributes[@CreationType='Run']/../Attributes[Name='Star
ted at']/Value">
Then sorting by the "Started at" value, then doing an xsl:if to get only the
runs that are related to the particular Job.
Unfortunately, this change of focus means that I have to redo everything
that comes next in the stylesheet.

Any suggestions?

Walter Crockett
 

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


Current Thread
  • Sorting Problem
    • walter . crockett - Mon, 14 Apr 2003 13:45:53 -0400 (EDT) <=
      • <Possible follow-ups>
      • cknell - Mon, 14 Apr 2003 16:36:04 -0400 (EDT)

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.