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

One Strange Problem

Subject: One Strange Problem
From: Myee.Riri@xxxxxxxxxx
Date: Fri, 7 May 2004 14:49:55 +1000
xsl sort scope
Hi,

I am new to XML/XSL land. I only started learning 2 days ago so please bear
with me. Don't worry about sounding patronising or anything, just serve it
to me cold.

I have an XML file which is generated by a Domino Agent. This xml file is
transformed by XSL and then displayed in a HTML page. The HTML page is
generated from a domino form and Agent (domino program), and has a form
with hidden fields in it. One of the hidden fields (SortVal) value is the
xml tag that I want to use to sort in my xsl.

I have a xsl:param called sortby, which I change to the value of SortVal
using javascript in the HTML page. So I want to sort each viewentry by
$sortval, however I don't really have any idea what I am doing.
Additionally I need to sort by date and I am aware there is no way to sort
by date, so I made somthing up.

I have been told the code is bad, but I can't change it since that would
involve changing the agent that creates it (which is unfeasible because
this agent creates more than one xml file depending on variables, and
changing it could affect other xml files and xsl stylesheets, and I don't
have the time). The only thing that is feasible to change is the xsl.

The file does not sort at all.

Here is a snippet of the xml populated with dummy data. The root tag is
called <viewentries>. It contains tages other than <viewentry> that are not
relevent so Ihave omitted them.


      <viewentry position="1" noteid="docnoteid1">
            <DateVal>01/02/2005</DateVal>
            <TimeVal>55555</TimeVal>
            <EntryNo>10</EntryNo>
            <Comments>I gots something to tell ya</Comments>
            <EnterBy>ANAME</EnterBy>
            <EnterDate>08/05/2003</EnterDate>
            <Action/>
            <RowNo>1</RowNo>
      </viewentry>
      <viewentry position="2" noteid="docnoteid1">
            <DateVal>27/02/2001</DateVal>
            <TimeVal>44444</TimeVal>
            <EntryNo>1</EntryNo>
            <Comments>Test Comment</Comments>
            <EnterBy>QNAME</EnterBy>
            <EnterDate>08/05/2003</EnterDate>
            <Action/>
            <RowNo>2</RowNo>
      </viewentry>
      <viewentry position="3" noteid="docnoteid1">
            <DateVal>31/12/2004</DateVal>
            <TimeVal>11111</TimeVal>
            <EntryNo>3</EntryNo>
            <Comments>Test another commet</Comments>
            <EnterBy>ZNAME</EnterBy>
            <EnterDate>08/05/2003</EnterDate>
            <Action/>
            <RowNo>4</RowNo>
      </viewentry>

here is the main snippets causing problems in my xsl

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version
="1.0">
      <xsl:param name="sortby">DateVal</xsl:param>
      <xsl:param name="datatype">number</xsl:param>

.........................................................................

.........................................................................

.........................................................................
      <xsl:template match="viewentries/viewentry">
            <div class="child" id="Sheet Entry">
            <table class="standard" cellspacing="0" cellpadding="0">
                  <xsl:if test="$sortby='DateVal'">
                              <xsl:for-each select="DateVal">
                                    <xsl:sort select="substring(. , 7,2)"
order="ascending" data-type="number"/>
                                    <xsl:sort select="substring(. , 4,2)"
order="ascending" data-type="number"/>
                                    <xsl:sort select="substring(. , 1,2)"
order="ascending" data-type="number"/>
                                    <xsl:value-of select="."/>
                              </xsl:for-each>
                  </xsl:if>
                  <xsl:if test="$sortby='EnterBy' ">
                        <xsl:for-each select="/viewentries/viewentry">
                              <xsl:sort select="$sortby" data-type="text"
/>
                        </xsl:for-each>
                  </xsl:if>
                  <xsl:if test="$sortby='EntryNo'">
                        <xsl:for-each select="/viewentries/viewentry">
                              <xsl:sort select="$sortby" data-type="number"
/>
                        </xsl:for-each>
                  </xsl:if>
                              <xsl:choose>
                                    <xsl:when test="RowNo/text()">
                                          <tr class="comments">
                                                <td width="658" colspan
="3">
                                                      <hr width="658" align
="left" valign="bottom"/>
                                                </td>
                                          </tr>

                                    </xsl:when>
                                    <xsl:otherwise>
                                          <tr class="comments">
                                                <td width="658" colspan
="3">
                                                      <hr width="90" align
="left" valign="bottom"/>
                                                </td>
                                          </tr>
                                    </xsl:otherwise>
                              </xsl:choose>

                              <tr class="title">
                                    <td width="90">Date</td>
                                    <td width="396" class
="commentstitle">Comments</td>
                                    <td width="153">Entered By</td>
                              </tr>
                              <tr class="content">
                                    <td width="90">
                                          <xsl:value-of select="DateVal"/>
                                    </td>
                                    <td width="396" rowspan="5" valign
="top" class="comments">
                                          <xsl:value-of select="Comments"/>
                                    </td>
                                    <td width="153">
                                          <xsl:value-of select="EnterBy"/>
                                    </td>
                              </tr>
                              <tr class="title">
                                    <td width="90">Time</td>
                                    <td width="153">Entered Date</td>
                              </tr>
                              <tr class="content">
                                    <td width="90">
                                          <xsl:value-of select="TimeVal"/>
                                    </td>
                                    <td width="153">
                                          <xsl:value-of select
="EnterDate"/>
                                    </td>
                              </tr>
                              <tr class="title">
                                    <td width="90">Entry No</td>
                                    <td width="153">Action Req.</td>
                              </tr>
                              <tr class="content">
                                    <td width="90">
                                          <xsl:value-of select="EntryNo"/>
                                    </td>
                                    <td width="153">
                                          <xsl:value-of select="Action"/>
                                    </td>
                              </tr>
                        </table>
                        <br/>
                  </div>
      </xsl:template>
</xsl:stylesheet>

The value of $sortby is correctly changed by js, I have checked that. I was
told it's a problem relating to where I put my sort stuff, and scope. I
tried moving stuff around and I got a lot of errors.

Can anyone suggest ways to improve/fix my xsl?

Thankyou in advanced.

P.S. I can tell I will not get much work done anymore since I will be
reading everyones emails all the time :)





****************************************************************
NOTICE - This message is intended only for the use of the 
addressee named above and may contain privileged and 
confidential information.  If you are not the intended recipient
of this message you are hereby notified that you must not 
disseminate, copy or take any action based upon it.  If you 
received this message in error please notify HIC immediately.
Any views expressed in this message are those of the individual
sender, except where the sender specifically states them to be
the views of HIC.
****************************************************************

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.