Subject: [xsl] Sorting Problem From: walter.crockett@xxxxxxxxxxxxxxxxxxxxx Date: Mon, 14 Apr 2003 13:48:30 -0400 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] using node fragments, Woody | Thread | RE: [xsl] Sorting Problem, cknell |
RE: [xsl] using node fragments, Passin, Tom | Date | [xsl] Optimizing a XSLT, Eric Barre |
Month |