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

RE: What am I doing wrong?

Subject: RE: What am I doing wrong?
From: Pieter Reint Siegers Kort <pieter.siegers@xxxxxxxxxxx>
Date: Fri, 24 Sep 2004 09:27:58 -0500
xsl if first
Sorry, the line

Here, you also add a <td> node element to the output if <AssociateValue>
exist. This will leave you with another empty cell.

Should read

Here, you also add a <td> node element to the output if <AssociateValue>
exist. If not, then this will leave you with another empty cell.

Cheers,
<prs/> 

-----Original Message-----
From: Pieter Reint Siegers Kort [mailto:pieter.siegers@xxxxxxxxxxx] 
Sent: Friday, September 24, 2004 9:26 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  What am I doing wrong?

Hi Arun,

First of all, your XML is not well-formed, but it may just be a typo: at the
end, <TabularReport> should be </TabularReport>.

Then, you are inserting two <td> elements when the test <xsl:when
test="$row-id = $first-row-id"> is evaluated to true, but only when there is
a child node element named 'AssociateValue'. If it's not there, only one
<td> is generated, but you have a problem when two <td>s are generated, and
on subsequent rows there's only one.

        <xsl:choose>
            <xsl:when test="$row-id = $first-row-id">
                <td>abc<xsl:value-of select="child::GroupValue" /></td>
                <xsl:if test="child::AssociateValue[1]">
                    <td>def<xsl:value-of select="child::AssociateValue[1]"
/></td>
                </xsl:if>
            </xsl:when>
            <xsl:otherwise>
                <td>xxx</td>
            </xsl:otherwise>
        </xsl:choose>

The same problem goes for the next template:

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

Here, you also add a <td> node element to the output if <AssociateValue>
exist. This will leave you with another empty cell.

In HTML tables, to test, first I always set the border attribute of the
<table> to "1", and all table cells, if you fill them with nothing, fill
them better with something like 'xxx'. Then you know where your logic goes
wrong, and with a debug in for example Xselerator 2.6 you soon know what's
going on.

I do not have the time to help you more, but I do hope you can do something
useful with it. You may be lucky and find that someone else on the list
provides a complete solution. It often happens. 

Cheers,
<prs/>


-----Original Message-----
From: Arun Sinha [mailto:arunsinha666@xxxxxxxxxxx]
Sent: Friday, September 24, 2004 4:20 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  What am I doing wrong?


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

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.