Altova Mailing List Archives


XSLT's with Cocoon

From: "Simon McClenahan" <Simon@-------->
To:
Date: 11/8/1999 8:35:00 AM
I am using Cocoon 1.5 with XSL:P which implements the XSLT WD 1.0 19990421. The next release of Cocoon will support XT, but I would like to get my current problem solved using an "official" release of Cocoon, and I seem to be stuck with XSL:P.

I want to detect a change in the value of <STAT_CATEGORY> for each <ROW>. I thought I could create <xsl:variable>s to save the last <STAT_CATEGORY>, but I soon found out that this is not possible! So I read up on XPath and XSLT working drafts, and only recently discovered that XSL:P implements a relatively old version. Because Cocoon does not give me any clue to any XSL processing errors or warnings, I have done a lot of trial and error trying to figure this out.

I am using the following edited XML data (re-formatted by hand because the SQLProcessor doesn't have a "pretty" option):

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="dashboard.xsl" type="text/xsl"?>
<?cocoon-process type="xslt"?>
<page>
<ROWSET>
<ROW ID="0">
<ORDER_NBR>0</ORDER_NBR>
<STAT_CATEGORY>Sales</STAT_CATEGORY>
<STAT_TITLE>SS Sales</STAT_TITLE>
<SAMPLE_VALUE>-999</SAMPLE_VALUE>
</ROW>

<ROW ID="1">
<ORDER_NBR>0</ORDER_NBR>
<STAT_CATEGORY>Sales</STAT_CATEGORY>
<STAT_TITLE>SS Sales</STAT_TITLE>
<SAMPLE_VALUE>118487391.17</SAMPLE_VALUE>
</ROW>

<ROW ID="9">
<ORDER_NBR>4</ORDER_NBR>
<STAT_CATEGORY>Sales</STAT_CATEGORY>
<STAT_TITLE>Total Sales</STAT_TITLE>
<SAMPLE_VALUE>289400790.91</SAMPLE_VALUE>
</ROW>
<ROW ID="10">
<ORDER_NBR>5</ORDER_NBR>
<STAT_CATEGORY>GP</STAT_CATEGORY>
<STAT_TITLE>SS GP</STAT_TITLE>
<SAMPLE_VALUE>-999</SAMPLE_VALUE>
</ROW>
<ROW ID="11">






My dashboard.xsl file looks like this (edited):

    <xsl:template match="ROWSET">
        <TABLE border="2" width="80%" cellspacing="1" cellpadding="1">
            <xsl:for-each select="ROW">
                <xsl:choose>
                    <xsl:when test="SAMPLE_VALUE=(-999)">
                        <xsl:value-of select="../ROW[@ID=(current()/@ID-1)]/@ID"/>;
                        <xsl:value-of select="from-preceding-siblings(.[position()=1]/@ID)"/>;
                        <xsl:choose>
                            <xsl:when test="not(//ROW[@ID=(../@ID-1))]/STAT_CATEGORY = STAT_CATEGORY)">
                                <TR>
                                    <xsl:apply-templates/>
                                </TR>
                            </xsl:when>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:otherwise>
                        <TR>
                            <xsl:apply-templates/>
                        </TR>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each>
        </TABLE>
    </xsl:template>


I'm obviously using the <xsl:value-of> to print out some values to see if they will work in a test attribute. The first one is what I think it should be. The second one is my attempt at using the 19990421 WD. The <xsl:when> is an example of what does not work, as explained in the most recent WD (but I have it in there so I can get some sort of output).

So, my question is, how do I do this with XSL:P and XT?


cheers,
    Simon



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.