473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

help on XSL sorting

Please help me on this ... i have just started working with XSL, and i need to complete this by weekend.

Here is the input :
<ussco:ItemPricing>
<ussco:ItemList>
<ussco:ListStartDate>01/01/2007</ussco:ListStartDate>
<ussco:ListEndDate>12/31/2010</ussco:ListEndDate>
<ussco:ListAmount currencyID="USD">13.79</ussco:ListAmount>
<ussco:ListUnitCode>KT</ussco:ListUnitCode>
</ussco:ItemList>
<ussco:ItemList>
<ussco:ListStartDate>10/08/2004</ussco:ListStartDate>
<ussco:ListEndDate>12/31/2006</ussco:ListEndDate>
<ussco:ListAmount currencyID="USD">8.95</ussco:ListAmount>
<ussco:ListUnitCode>KT</ussco:ListUnitCode>
</ussco:ItemList>
<ussco:ItemCost>
<ussco:CostType>FC</ussco:CostType>
<ussco:CostStartDate>01/01/2007</ussco:CostStartDate>
<ussco:CostEndDate>12/31/2010</ussco:CostEndDate>
<oagis:CostAmount currencyID="USD">5.170</oagis:CostAmount>
<ussco:CostUnitCode>KT</ussco:CostUnitCode>
</ussco:ItemCost>
<ussco:ItemCost>
<ussco:CostType>FC</ussco:CostType>
<ussco:CostStartDate>10/08/2004</ussco:CostStartDate>
<ussco:CostEndDate>12/31/2006</ussco:CostEndDate>
<oagis:CostAmount currencyID="USD">4.470</oagis:CostAmount>
<ussco:CostUnitCode/>
</ussco:ItemCost>
<ussco:ItemCost>
<ussco:CostType>PR</ussco:CostType>
<ussco:CostStartDate>12/10/2007</ussco:CostStartDate>
<ussco:CostEndDate>06/30/2008</ussco:CostEndDate>
<oagis:CostAmount currencyID="USD">3.860</oagis:CostAmount>
<ussco:CostUnitCode>KT</ussco:CostUnitCode>
</ussco:ItemCost>
<ussco:ItemCost>
<ussco:CostType>PR</ussco:CostType>
<ussco:CostStartDate>11/01/2007</ussco:CostStartDate>
<ussco:CostEndDate>06/30/2008</ussco:CostEndDate>
<oagis:CostAmount currencyID="USD">4.653</oagis:CostAmount>
<ussco:CostUnitCode/>
</ussco:ItemCost>

This is the output expected :
<ItemMaster xmlns:us="http://www.ussco.com/oagis/0">
<CostLineInq>
<ShortName>AMERAC</ShortName>
<ListStartDate>01/01/2007</ListStartDate>
<ListEndDate>12/31/2010</ListEndDate>
<ListAmount>13.79</ListAmount>
<ListUnitCode>KT</ListUnitCode>
<CostStartDate>01/01/2007</CostStartDate>
<CostEndDate>12/31/2010</CostEndDate>
<CostAmount>5.170</CostAmount>
<CostUnitCode>FC</CostUnitCode>
</CostLineInq>
<CostLineInq>
<ShortName>AMERAC</ShortName>
<ListStartDate>10/08/2004</ListStartDate>
<ListEndDate>12/31/2006</ListEndDate>
<ListAmount>8.95</ListAmount>
<ListUnitCode>KT</ListUnitCode>
<CostStartDate>12/10/2007</CostStartDate>
<CostEndDate>06/30/2008</CostEndDate>
<CostAmount>3.860</CostAmount>
<CostUnitCode>PR</CostUnitCode>
</CostLineInq>
<CostLineInq>
<ShortName>AMERAC</ShortName>
<ListStartDate></ListStartDate>
<ListEndDate></ListEndDate>
<ListAmount></ListAmount>
<ListUnitCode></ListUnitCode>
<CostStartDate>11/01/2007</CostStartDate>
<CostEndDate>06/30/2008</CostEndDate>
<CostAmount>4.653</CostAmount>
<CostUnitCode>PR</CostUnitCode>
</CostLineInq>
<CostLineInq>
<ShortName>AMERAC</ShortName>
<ListStartDate></ListStartDate>
<ListEndDate></ListEndDate>
<ListAmount></ListAmount>
<ListUnitCode></ListUnitCode>
<CostStartDate>10/08/2004</CostStartDate>
<CostEndDate>12/31/2006</CostEndDate>
<CostAmount>4.470</CostAmount>
<CostUnitCode>FC</CostUnitCode>
</CostLineInq>
</ItemMaster>

and here is the XSL i am struggling with to get the above output :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:oa="http://www.openapplications.org/oagis/9" xmlns:us="http://www.ussco.com/oagis/0">
<xsl:output method="xml" version="1.0" encoding="UTF-16" indent="yes"/>
<xsl:namespace-alias stylesheet-prefix="oa" result-prefix="oa"/>
<xsl:template match="/">
<ItemMaster>
<xsl:variable name="ShortName" select="//us:ItemMaster/us:ItemMasterHeader/oa:ManufacturerItemID/oa:ID/@schemeAgencyName"/>
<xsl:for-each select="//us:ItemPricing">

<xsl:variable name="currentPricingNode" select="."/>
<xsl:for-each select="us:ItemCost">

<xsl:sort select="substring(us:CostEndDate,7,4)" order="descending"/> <!-- year -->


<xsl:variable name="costIndex" select="position()"/>
<CostLineInq>
<ShortName>
<xsl:value-of select="$ShortName"/>
</ShortName>
<ListStartDate>

<xsl:value-of select="$currentPricingNode/us:ItemList[$costIndex]/us:ListStartDate"/>
</ListStartDate>
<ListEndDate>
<xsl:value-of select="$currentPricingNode/us:ItemList[$costIndex]/us:ListEndDate"/>
</ListEndDate>
<ListAmount>
<xsl:value-of select="$currentPricingNode/us:ItemList[$costIndex]/us:ListAmount"/>
</ListAmount>
<ListUnitCode>
<xsl:value-of select="$currentPricingNode/us:ItemList[$costIndex]/us:ListUnitCode"/>
</ListUnitCode>
<CostStartDate>

<xsl:value-of select="us:CostStartDate"/>
</CostStartDate>
<CostEndDate>
<xsl:value-of select="us:CostEndDate"/>
</CostEndDate>
<CostAmount>
<xsl:value-of select="$currentPricingNode/us:ItemCost[$costIndex]/oa:CostAmount"/>
</CostAmount>
<CostUnitCode>
<xsl:value-of select="$currentPricingNode/us:ItemCost[$costIndex]/us:CostType"/>
</CostUnitCode>
</CostLineInq>
</xsl:for-each>
</xsl:for-each>
</ItemMaster>
</xsl:template>
</xsl:stylesheet>

Any help in this regard is greatly appreciated... thanks in advance for the help
Mar 6 '08 #1
0 915

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: dont bother | last post by:
This is really driving me crazy. I have a dictionary feature_vectors{}. I try to sort its keys using #apply sorting on feature_vectors sorted_feature_vector=feature_vectors.keys()...
2
by: D. Roshani | last post by:
Hello ! I wonder if any one can help me to create a cosomize sorting order (as Macro or added small program in c++ or c# which does this work) in a Access Database contaning one table only words...
3
by: Neil Hindry | last post by:
I wonder if you can help me. I have setup an address-book database in Access XP. I have the first name & surname as separate fields. As I wanted to sort my database by surname and then by first...
1
by: aredo3604gif | last post by:
On Sun, 10 Apr 2005 19:46:32 GMT, aredo3604gif@yahoo.com wrote: >The user can dynamically enter and change the rule connection between >objects. The rule is a "<" and so given two objects: >a <...
3
by: Don | last post by:
I have a "Report" that is created from a "Form". It prints a list of items, you may consider it a shopping list. In any event I use to run this in alphabetical order but have since decided to run...
2
by: rookiejavadude | last post by:
I'm have most of my java script done but can not figure out how to add a few buttons. I need to add a delete and add buttong to my existing java program. Not sure were to add it on how. Can anyone...
1
by: Ahmed Yasser | last post by:
Hi all, i have a problem with the datagridview sorting, the problem is a bit complicated so i hope i can describe in the following steps: 1. i have a datagridview with two columns...
1
KevinADC
by: KevinADC | last post by:
Introduction In part one we discussed the default sort function. In part two we will discuss more advanced techniques you can use to sort data. Some of the techniques might introduce unfamiliar...
6
by: gopalsd | last post by:
Hi Friends, Can anyone pls help me to resolve my school test in PERL................ as follows..... #!/usr/bin/perl @data=N; $sum=0; print"enter the required No. of numbers to be inputed...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.