[xsl] What am I doing wrong?

Subject: [xsl] What am I doing wrong?
From: "Arun Sinha" <arunsinha666@xxxxxxxxxxx>
Date: Fri, 24 Sep 2004 09:20:09 +0000
Hi,

Anybody who can point what am i doing wrong? I am not getting the
desired output.

The first line is correct but after that three subsequent lines are not.
The output is missing one '<td></td>' somehow for those three lines.

Thanks in advance.

Arun


Here is the XML file :-



<?xml version='1.0' encoding='UTF-8' standalone='yes' ?> <TabularReport> <Titles> <Title>Supplier</Title> <Title>Name</Title> <Title>Order No</Title> <Title>Order Line</Title> <Title>Part</Title> <Title>Net Value</Title> <Title>Date Requested</Title> <Title>Qty Required</Title> <Title>Order Status</Title> <Title>Exch Rate</Title> </Titles>

<Group>
   <GroupValue type='alpha'>SUPP1</GroupValue>
   <AssociateValue type='alpha'>Software House</AssociateValue>
   <Group>
       <GroupValue type='alpha'>PO000001</GroupValue>
       <AssociateValue type='numeric'>1</AssociateValue>
       <Row>
           <ColumnValue type='alpha'>SU-1000</ColumnValue>
           <ColumnValue type='numeric'>840</ColumnValue>
           <ColumnValue type='date'>12/06/2000</ColumnValue>
           <ColumnValue type='numeric'>24</ColumnValue>
           <ColumnValue type='alpha'>Released</ColumnValue>
           <ColumnValue type='numeric'>1.00000000</ColumnValue>
       </Row>
       <AssociateValue type='numeric'>2</AssociateValue>
       <Row>
           <ColumnValue type='alpha'>BOX-1</ColumnValue>
           <ColumnValue type='numeric'>0</ColumnValue>
           <ColumnValue type='date'>12/06/2000</ColumnValue>
           <ColumnValue type='numeric'>1</ColumnValue>
           <ColumnValue type='alpha'>Released</ColumnValue>
           <ColumnValue type='numeric'>1.00000000</ColumnValue>
       </Row>
       <AssociateValue type='numeric'>10</AssociateValue>
       <Row>
           <ColumnValue type='alpha'>BOX-2</ColumnValue>
           <ColumnValue type='numeric'>20</ColumnValue>
           <ColumnValue type='date'>31/12/2003</ColumnValue>
           <ColumnValue type='numeric'>20</ColumnValue>
           <ColumnValue type='alpha'>Released</ColumnValue>
           <ColumnValue type='numeric'>1.00000000</ColumnValue>
       </Row>
   </Group>
   <Group>
       <GroupValue type='alpha'>PO000005</GroupValue>
       <AssociateValue type='numeric'>1</AssociateValue>
       <Row>
           <ColumnValue type='alpha'>CD-2000</ColumnValue>
           <ColumnValue type='numeric'>0</ColumnValue>
           <ColumnValue type='date'>12/07/2003</ColumnValue>
           <ColumnValue type='numeric'>10</ColumnValue>
           <ColumnValue type='alpha'>Released</ColumnValue>
           <ColumnValue type='numeric'>1.00000000</ColumnValue>
       </Row>
   </Group>
</Group>
<TabularReport>

Following is the XSL :-

<?xml version="1.0" ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="/TabularReport">

   <html><head><title></title></head><body><left>
   <table>
       <tr>
       <xsl:apply-templates select="Titles/Title" />
       <xsl:apply-templates select=".//Row" />
       </tr>
   </table>
   </left></body></html>

</xsl:template>

<xsl:template match="Row">
<xsl:variable name="row-id" select="generate-id(.)" />
<tr>
<xsl:for-each select="ancestor::Group">
<xsl:variable name="first-row-id" select="generate-id(descendant::Row[1])" />
<xsl:choose>
<xsl:when test="$row-id = $first-row-id">
<td><xsl:value-of select="child::GroupValue" /></td>
<xsl:if test="child::AssociateValue[1]">
<td><xsl:value-of select="child::AssociateValue[1]" /></td>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<td></td>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>


<xsl:if test="name(preceding-sibling::node()[2]) != 'GroupValue'">
<xsl:if test="preceding-sibling::AssociateValue[1]">
<td><xsl:value-of select="preceding-sibling::AssociateValue[1]" /></td>
</xsl:if>
</xsl:if>
<xsl:apply-templates select="ColumnValue" />
</tr>
</xsl:template>


<xsl:template match="Title">
   <td><font color="red" size="2pt"><xsl:value-of select="." /></font></td>
</xsl:template>

<xsl:template match="ColumnValue">
<td><font color="black" size="2pt"><xsl:value-of select="." /></font></td>
</xsl:template>


</xsl:stylesheet>

_________________________________________________________________
The new MSN toolbar! Your shortcut to the internet! http://toolbar.msn.co.in/ Access a world of convenience!


Current Thread