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