OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Strange Sorting Problem

[ Lists Home | Date Index | Thread Index ]

hey all
am fairly new to xslt and am having trouble getting the following sort
routine to work. basically i wish to sort dynamically but whilst the
variable i am using to implement the sort is populated it doesn't work.
am sure i have just missed something simple but would appreciate some
guidance.

will append the xml and xslt inline. sorry for the bucket load of code
but thought it best! ;)

###   XML

<staffware viewcompany="-1" viewdepartment="-1" viewwork="-1" search="0"
company="ABN" sortfield="@caseref">
      <workitems workitemcount="23">
            <department deptname="Registration">Registration<workitem
caserefopen="caseopen56-63:IRACTION@staffw_nod1|614418" caseref="56-63"
casedesc="00002615" deadline="26/11/2003 05:00:00 pm" priority="40"
isurgent="false" isdeadline="true" isunopen="false" stepname="ACTION"
stepdesc="Action Work Item" key="IRACTION@staffw_nod1|614418"
addrtoname="IRACTION@staffw_nod1" wq1="ABN - Edinburgh"
wq2="Registration" wq3="Change of Ad" wq4="*" lockedby="swadmin"
audit="audittrail56-63:IRACTION@staffw_nod1|614418">63</workitem>
                  <workitem
caserefopen="caseopen56-47:IRACTION@staffw_nod1|679960" caseref="56-47"
casedesc="00002613" deadline="27/11/2003 05:00:00 pm" priority="40"
isurgent="false" isdeadline="true" isunopen="false" stepname="ACTION"
stepdesc="Action Work Item" key="IRACTION@staffw_nod1|679960"
addrtoname="IRACTION@staffw_nod1" wq1="ABN - London HEX"
wq2="Registration" wq3="Deceaseds" wq4="*" lockedby="*"
audit="audittrail56-47:IRACTION@staffw_nod1|679960">47</workitem>
                  <workitem
caserefopen="caseopen56-49:IRACTION@staffw_nod1|671783" caseref="56-49"
casedesc="00002613" deadline="27/11/2003 05:00:00 pm" priority="40"
isurgent="false" isdeadline="true" isunopen="false" stepname="ACTION"
stepdesc="Action Work Item" key="IRACTION@staffw_nod1|671783"
addrtoname="IRACTION@staffw_nod1" wq1="ABN - London HEX"
wq2="Registration" wq3="Other Legal" wq4="*" lockedby="*"
audit="audittrail56-49:IRACTION@staffw_nod1|671783">49</workitem>
                  <workitem
caserefopen="caseopen56-48:IRACTION@staffw_nod1|675878" caseref="56-48"
casedesc="00002613" deadline="27/11/2003 05:00:00 pm" priority="40"
isurgent="false" isdeadline="true" isunopen="false" stepname="ACTION"
stepdesc="Action Work Item" key="IRACTION@staffw_nod1|675878"
addrtoname="IRACTION@staffw_nod1" wq1="ABN - London HEX"
wq2="Registration" wq3="Power of Att" wq4="*" lockedby="*"
audit="audittrail56-48:IRACTION@staffw_nod1|675878">48</workitem>
                  <workitem
caserefopen="caseopen56-51:IRACTION@staffw_nod1|663580" caseref="56-51"
casedesc="00002613" deadline="27/11/2003 05:00:00 pm" priority="40"
isurgent="false" isdeadline="true" isunopen="false" stepname="ACTION"
stepdesc="Action Work Item" key="IRACTION@staffw_nod1|663580"
addrtoname="IRACTION@staffw_nod1" wq1="ABN - London HEX"
wq2="Registration" wq3="Replacement " wq4="*" lockedby="*"
audit="audittrail56-51:IRACTION@staffw_nod1|663580">51</workitem>
                  <workitem
caserefopen="caseopen56-50:IRACTION@staffw_nod1|667685" caseref="56-50"
casedesc="00002613" deadline="27/11/2003 05:00:00 pm" priority="40"
isurgent="false" isdeadline="true" isunopen="false" stepname="ACTION"
stepdesc="Action Work Item" key="IRACTION@staffw_nod1|667685"
addrtoname="IRACTION@staffw_nod1" wq1="ABN - London HEX"
wq2="Registration" wq3="Tax Vouchers" wq4="*" lockedby="*"
audit="audittrail56-50:IRACTION@staffw_nod1|667685">50</workitem>
                  <workitem
caserefopen="caseopen56-64:IRDISTREG@staffw_nod1|143383" caseref="56-64"
casedesc="00002615" deadline="26/11/2003 05:00:00 pm" priority="40"
isurgent="false" isdeadline="true" isunopen="true" stepname="DISTWORK"
stepdesc="Distribute Work" key="IRDISTREG@staffw_nod1|143383"
addrtoname="IRDISTREG@staffw_nod1" wq1="ABN - Edinburgh"
wq2="Registration" wq3="Mandates" wq4="*" lockedby="*"
audit="audittrail56-64:IRDISTREG@staffw_nod1|143383">64</workitem>
                  <workitem
caserefopen="caseopen56-52:IRDISTREG@staffw_nod1|147486" caseref="56-52"
casedesc="00002613" deadline="21/11/2003 02:19:00 pm" priority="40"
isurgent="false" isdeadline="true" isunopen="true" stepname="DISTWORK"
stepdesc="Distribute Work" key="IRDISTREG@staffw_nod1|147486"
addrtoname="IRDISTREG@staffw_nod1" wq1="ABN - London HEX"
wq2="Registration" wq3="Queries" wq4="*" lockedby="*"
audit="audittrail56-52:IRDISTREG@staffw_nod1|147486">52</workitem>
                  <workitem
caserefopen="caseopen56-53:IRDISTREG@staffw_nod1|139295" caseref="56-53"
casedesc="00002613" deadline="27/11/2003 05:00:00 pm" priority="40"
isurgent="false" isdeadline="true" isunopen="false" stepname="DISTWORK"
stepdesc="Distribute Work" key="IRDISTREG@staffw_nod1|139295"
addrtoname="IRDISTREG@staffw_nod1" wq1="ABN - London HEX"
wq2="Registration" wq3="Signature" wq4="*" lockedby="*"
audit="audittrail56-53:IRDISTREG@staffw_nod1|139295">53</workitem>
            </department>
      </workitems>
</staffware>

###   XML

###   XSLT

<?xml version='1.0'?>

<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'>
      <xsl:output method='html' standalone='yes'
omit-xml-declaration='yes'/>
      <xsl:template match='/'>
            <xsl:variable name="sort_field"
select="staffware/@sortfield"/>
            <table width='100%' cellpadding='2' cellspacing='2'
border='1'>
                  <tr>
                        <xsl:choose>
                              <xsl:when test='staffware/@viewcompany
= "-1"'>
                                    <td colspan='10' id='title'
class='bkbutton'>
                                          <nobr>
                                                <a>
                                                      <xsl:attribute
name="HREF">viewcompany</xsl:attribute>
                                                      <xsl:attribute
name="title">Navigate to the Company screen</xsl:attribute>
                                                      <xsl:text>Navigate
to the Company screen</xsl:text>
                                                </a>
                                          </nobr>
                                    </td>
                              </xsl:when>
                              <xsl:otherwise>
                                    <td colspan='10'>
                                    </td>
                              </xsl:otherwise>
                        </xsl:choose>
                  </tr>
            </table>
            <table width='100%' cellpadding='2' cellspacing='2'
border='1'>
                  <tr>
                        <td colspan='10' width='100%' id='header'
class="tablehrwi">
                              <nobr>
                                    <xsl:value-of
select='staffware/@company'/> Workitems</nobr>
                        </td>
                  </tr>
                  <tr>
                        <td width='5%' id='header' name='SW_CASEREF'
class="tablehrwi">
                              <xsl:attribute name="title">[Case Ref] -
Unique reference for each workitem.</xsl:attribute>
                              <nobr>
                                    <a href='casesortSW_CASEREF'>Case
Ref  </a>
                              </nobr>
                              <xsl:choose>
                                    <xsl:when test='staffware/@sortfield
= "SW_CASEREF"'>
                                          <img src='..\Images\asc.gif'>
                                          </img>
                                    </xsl:when>
                                    <xsl:otherwise>
                                          <img
src='..\Images\blank.gif'>
                                          </img>
                                    </xsl:otherwise>
                              </xsl:choose>
                        </td>
                        <td width='10%' id='header' name='SW_CASEDESC'
class="tablehrwi">
                              <xsl:attribute name="title">[Case
Description] - Descriptive information about each
workitem.</xsl:attribute>
                              <nobr>
                                    <a href='casesortSW_CASEDESC'>Case
Description  </a>
                              </nobr>
                              <xsl:choose>
                                    <xsl:when test='staffware/@sortfield
= "SW_CASEDESC"'>
                                          <img src='..\Images\asc.gif'>
                                          </img>
                                    </xsl:when>
                                    <xsl:otherwise>
                                          <img
src='..\Images\blank.gif'>
                                          </img>
                                    </xsl:otherwise>
                              </xsl:choose>
                        </td>
                        <td width='15%' id='header' name='SW_DEADLINE'
class="tablehrwi">
                              <xsl:attribute name="title">[Deadline] -
The date this workitem is due to expire and breach it's
SLA.</xsl:attribute>
                              <nobr>
                                    <a
href='casesortSW_DEADLINE'>Deadline  </a>
                              </nobr>
                              <xsl:choose>
                                    <xsl:when test='staffware/@sortfield
= "SW_DEADLINE"'>
                                          <img src='..\Images\asc.gif'>
                                          </img>
                                    </xsl:when>
                                    <xsl:otherwise>
                                          <img
src='..\Images\blank.gif'>
                                          </img>
                                    </xsl:otherwise>
                              </xsl:choose>
                        </td>
                        <td width='5%' id='header' name='SW_PRIORITY'
class="tablehrwi">
                              <xsl:attribute name="title">[Priority] -
The current priority level of this workitem. The lower the number, the
higher the priority.</xsl:attribute>
                              <nobr>
                                    <a
href='casesortSW_PRIORITY'>Priority  </a>
                              </nobr>
                              <xsl:choose>
                                    <xsl:when test='staffware/@sortfield
= "SW_PRIORITY"'>
                                          <img src='..\Images\asc.gif'>
                                          </img>
                                    </xsl:when>
                                    <xsl:otherwise>
                                          <img
src='..\Images\blank.gif'>
                                          </img>
                                    </xsl:otherwise>
                              </xsl:choose>
                        </td>
                        <td width='15%' id='header' name='SW_STEP'
class="tablehrwi">
                              <xsl:attribute name="title">[Queue] - The
resident queue for each workitem.</xsl:attribute>
                              <nobr>
                                    <a href='casesortSW_STEP'>Queue </a>
                              </nobr>
                              <xsl:choose>
                                    <xsl:when test='staffware/@sortfield
= "SW_CASEREF"'>
                                          <img src='..\Images\asc.gif'>
                                          </img>
                                    </xsl:when>
                                    <xsl:otherwise>
                                          <img
src='..\Images\blank.gif'>
                                          </img>
                                    </xsl:otherwise>
                              </xsl:choose>
                        </td>
                        <td width='15%' id='header' name='SW_QPARAM1'
class="tablehrwi">
                              <xsl:attribute
name="title">[Company/Location] - The company and location for each
workitem.</xsl:attribute>
                              <nobr>
                                    <a
href='casesortSW_QPARAM1'>Company/Location  </a>
                              </nobr>
                              <xsl:choose>
                                    <xsl:when test='staffware/@sortfield
= "SW_QPARAM1"'>
                                          <img src='..\Images\asc.gif'>
                                          </img>
                                    </xsl:when>
                                    <xsl:otherwise>
                                          <img
src='..\Images\blank.gif'>
                                          </img>
                                    </xsl:otherwise>
                              </xsl:choose>
                        </td>
                        <td width='10%' id='header' name='SW_QPARAM3'
class="tablehrwi">
                              <xsl:attribute name="title">[Queue] - The
work group of each workitem.</xsl:attribute>
                              <nobr>
                                    <a href='casesortSW_QPARAM3'>Work
Type  </a>
                              </nobr>
                              <xsl:choose>
                                    <xsl:when test='staffware/@sortfield
= "SW_QPARAM3"'>
                                          <img src='..\Images\asc.gif'>
                                          </img>
                                    </xsl:when>
                                    <xsl:otherwise>
                                          <img
src='..\Images\blank.gif'>
                                          </img>
                                    </xsl:otherwise>
                              </xsl:choose>
                        </td>
                        <td width='10%' id='header' name='SW_QPARAM4'
class="tablehrwi">
                              <xsl:attribute name="title">[Boxed] -
Whether the workitem has been boxed.</xsl:attribute>
                              <nobr>
                                    <a href='casesortSW_QPARAM4'>Boxed
</a>
                              </nobr>
                              <xsl:choose>
                                    <xsl:when test='staffware/@sortfield
= "SW_QPARAM4"'>
                                          <img src='..\Images\asc.gif'>
                                          </img>
                                    </xsl:when>
                                    <xsl:otherwise>
                                          <img
src='..\Images\blank.gif'>
                                          </img>
                                    </xsl:otherwise>
                              </xsl:choose>
                        </td>
                        <td width='10%' id='header' name='SW_LOCKEDBY'
class="tablehrwi">
                              <xsl:attribute name="title">[Locked By] -
The user who has the workitem item open.</xsl:attribute>
                              <nobr>
                                    <a href='casesortSW_LOCKEDBY'>Locked
By  </a>
                              </nobr>
                              <xsl:choose>
                                    <xsl:when test='staffware/@sortfield
= "SW_LOCKEDBY"'>
                                          <img src='..\Images\asc.gif'>
                                          </img>
                                    </xsl:when>
                                    <xsl:otherwise>
                                          <img
src='..\Images\blank.gif'>
                                          </img>
                                    </xsl:otherwise>
                              </xsl:choose>
                        </td>
                        <td width='5%' id='header' class="tablehrwi">
                              <xsl:attribute name="title">[Audit Trail]
- Click this link to view the audit trail for the
workitem.</xsl:attribute>
                              <nobr>Audit Trail</nobr>
                        </td>
                  </tr>
                  <xsl:for-each
select='/staffware/workitems/department'>
                        <tr>
                              <td colspan='10' width='100%' id='header'
class="tablehrwis">
                                    <xsl:attribute name="title">Work
Items for the <xsl:value-of select='@deptname'/>
department</xsl:attribute>
                                    <nobr>
                                          <xsl:value-of
select='@deptname'/>
                                    </nobr>
                              </td>
                        </tr>
                        <xsl:call-template name="workitem">
                              <xsl:with-param name="sorted_field"
select="$sort_field"/>
                        </xsl:call-template>
                  </xsl:for-each>
                  <tr>
                        <td colspan='10' id='header' class="tablehrwi">
                              <nobr>
                                          Number of items: <xsl:value-of
select='staffware/workitems/@workitemcount'/>
                              </nobr>
                        </td>
                  </tr>
                  <tr>
                        <xsl:choose>
                              <xsl:when test='staffware/@search = "-1"'>
                                    <td colspan='10' id='title'
class='bkbutton'>
                                          <nobr>
                                                <a>
                                                      <xsl:attribute
name="HREF">clearfilter</xsl:attribute>
                                                      <xsl:attribute
name="title">Clear the filter</xsl:attribute>
                                                      <xsl:text>Clear
the filter</xsl:text>
                                                </a>
                                          </nobr>
                                    </td>
                              </xsl:when>
                              <xsl:otherwise>
                                    <td colspan='10'>
                                    </td>
                              </xsl:otherwise>
                        </xsl:choose>
                  </tr>
                  <tr>
                        <td>
                              <div>
                              </div>
                        </td>
                  </tr>
            </table>
      </xsl:template>
      <xsl:template name="workitem">
            <xsl:for-each select="descendant::*">
<!--              <xsl:sort select='@wq2' order='ascending'></xsl:sort>
                  <xsl:sort select='@casedesc'
order='ascending'></xsl:sort>
                  <xsl:sort select='@priority'
order='ascending'></xsl:sort>-->
                  <xsl:sort select='$sorted_field' order='ascending'/>
                  <tr>
                        <xsl:choose>
                              <xsl:when test='@isurgent = "true"'>
                                    <td id='title' class='tabletxtiubl'>
                                          <nobr>
                                                <a>
                                                      <xsl:attribute
name="HREF">

<xsl:value-of select="@caserefopen"/>
                                                      </xsl:attribute>
                                                      <xsl:attribute
name="title">View the case <xsl:value-of select='@caseref'/>
                                                      </xsl:attribute>
                                                      <xsl:value-of
select='@caseref'/>
                                                </a>
                                          </nobr>
                                    </td>
                              </xsl:when>
                              <xsl:when test='@isdeadline = "true"'>
                                    <td id='title' class='tabletxtidbl'>
                                          <nobr>
                                                <a>
                                                      <xsl:attribute
name="HREF">

<xsl:value-of select="@caserefopen"/>
                                                      </xsl:attribute>
                                                      <xsl:attribute
name="title">View the case <xsl:value-of select='@caseref'/>
                                                      </xsl:attribute>
                                                      <xsl:value-of
select='@caseref'/>
                                                </a>
                                          </nobr>
                                    </td>
                              </xsl:when>
                              <xsl:when test='@lockedby = "*"'>
                                    <td id='title' class='tabletxtbl'>
                                          <nobr>
                                                <a>
                                                      <xsl:attribute
name="HREF">

<xsl:value-of select="@caserefopen"/>
                                                      </xsl:attribute>
                                                      <xsl:attribute
name="title">View the case <xsl:value-of select='@caseref'/>
                                                      </xsl:attribute>
                                                      <xsl:value-of
select='@caseref'/>
                                                </a>
                                          </nobr>
                                    </td>
                              </xsl:when>
                              <xsl:otherwise>
                                    <td id='title' class='tabletxtbgl'>
                                          <xsl:attribute
name="title">This case is currently locked by <xsl:value-of
select='@lockedby'/>
                                          </xsl:attribute>
                                          <nobr>
                                                <xsl:value-of
select='@caseref'/>
                                          </nobr>
                                    </td>
                              </xsl:otherwise>
                        </xsl:choose>
                        <xsl:choose>
                              <xsl:when test='@lockedby = "*"'>
                                    <td id='detail' class='tabletxtl'>
                                          <nobr>
                                                <xsl:value-of
select='@casedesc'/>
                                          </nobr>
                                    </td>
                                    <td id='detail' class="tabletxtl">
                                          <nobr>
                                                <xsl:value-of
select='@deadline'/>
                                          </nobr>
                                    </td>
                                    <td id='detail' class="tabletxtc">
                                          <nobr>
                                                <xsl:value-of
select='@priority'/>
                                          </nobr>
                                    </td>
                                    <td id='detail' class="tabletxtl">
                                          <nobr>
                                                <xsl:value-of
select='@stepdesc'/>
                                          </nobr>
                                    </td>
                                    <td id='detail' class="tabletxtl">
                                          <nobr>
                                                <xsl:value-of
select='@wq1'/>
                                          </nobr>
                                    </td>
                                    <td id='detail' class="tabletxtl">
                                          <nobr>
                                                <xsl:value-of
select='@wq3'/>
                                          </nobr>
                                    </td>
                                    <td id='detail' class="tabletxtl">
                                          <nobr>
                                                <xsl:value-of
select='@wq4'/>
                                          </nobr>
                                    </td>
                                    <td id='detail' class="tabletxtl">
                                          <nobr>
                                                <xsl:value-of
select='@lockedby'/>
                                          </nobr>
                                    </td>
                                    <xsl:choose>
                                          <xsl:when test='@audit = 0'>
                                                <td id='detail'
class='atbutton'>
                                                      <nobr>*</nobr>
                                                </td>
                                          </xsl:when>
                                          <xsl:otherwise>
                                                <td id='detail'
class='atbutton'>
                                                      <nobr>
                                                            <a>

<xsl:attribute name="HREF">

<xsl:value-of select="@audit"/>

</xsl:attribute>

<xsl:attribute name="title">View the audit trail for case <xsl:value-of
select='@caseref'/>

</xsl:attribute>Audit
                                                                  </a>
                                                      </nobr>
                                                </td>
                                          </xsl:otherwise>
                                    </xsl:choose>
                              </xsl:when>
                              <xsl:otherwise>
                                    <td id='detail' class='tabletxtgl'>
                                          <nobr>
                                                <xsl:value-of
select='@casedesc'/>
                                          </nobr>
                                    </td>
                                    <td id='detail' class="tabletxtgl">
                                          <nobr>
                                                <xsl:value-of
select='@deadline'/>
                                          </nobr>
                                    </td>
                                    <td id='detail' class="tabletxtgc">
                                          <nobr>
                                                <xsl:value-of
select='@priority'/>
                                          </nobr>
                                    </td>
                                    <td id='detail' class="tabletxtl">
                                          <nobr>
                                                <xsl:value-of
select='@stepdesc'/>
                                          </nobr>
                                    </td>
                                    <td id='detail' class="tabletxtgl">
                                          <nobr>
                                                <xsl:value-of
select='@wq1'/>
                                          </nobr>
                                    </td>
                                    <td id='detail' class="tabletxtgl">
                                          <nobr>
                                                <xsl:value-of
select='@wq3'/>
                                          </nobr>
                                    </td>
                                    <td id='detail' class="tabletxtgl">
                                          <nobr>
                                                <xsl:value-of
select='@wq4'/>
                                          </nobr>
                                    </td>
                                    <td id='detail' class="tabletxtgl">
                                          <nobr>
                                                <xsl:value-of
select='@lockedby'/>
                                          </nobr>
                                    </td>
                                    <xsl:choose>
                                          <xsl:when test='@audit = 0'>
                                                <td id='detail'
class='atbutton'>
                                                      <nobr>*</nobr>
                                                </td>
                                          </xsl:when>
                                          <xsl:otherwise>
                                                <td id='detail'
class='atbuttong'>
                                                      <nobr>

<xsl:attribute name="title">View the audit trail for case <xsl:value-of
select='@caseref'/>

</xsl:attribute>Audit
                                                      </nobr>
                                                </td>
                                          </xsl:otherwise>
                                    </xsl:choose>
                              </xsl:otherwise>
                        </xsl:choose>
                  </tr>
            </xsl:for-each>
      </xsl:template>
</xsl:stylesheet>

###   XSLT
                                                                         
                                                                         
                                                                         
 Regards                                                                 
                                                                         
                                                                         
                                                                         
 Christopher Beach MCP                                                   
                                                                         
 Senior Software Developer                                               
                                                                         
 Assistant Treasurer                                                     
                                                                         
                                                                         
                                                                         
 The Bank of New York Europe Limited                                     
                                                                         
 Direct: +44 (0)20 7964 5344                                             
                                                                         
 Switch: +44 (0)20 7512 3784                                             
                                                                         
 Email: cbeach@bankofny.com                                              
                                                                         
 Web: www.bankofny.com                                                   
                                                                         






________________________________________________________________________
The information in this e-mail, and any attachment therein, is confidential and for use by the addressee only. If you are not the intended recipient, please return the e-mail to the sender and delete it from your computer. Although The Bank of New York attempts to sweep e-mail and attachments for viruses, it does not guarantee that either are virus-free and accepts no liability for any damage sustained as a result of viruses.




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS