Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Parameterizing a generic filter and sort routine in xsl

From: canopus56@-----.--- (-------)
To: NULL
Date: 11/30/2004 6:54:00 PM
I am trying to implement a basic filter and sort table in xml-xsl
using MS-IE 6.0.  Although I have my XML application running with
hard-coded sort and filter criteria, I would like to parameterize the
basic filter and sort process.  After studying several books and
historical posts in this usenet group,  I could not get the thing to
work. I am assuming there is some syntax usage that I am simply not
getting. After trying numerous syntax variants, they either won't
compile, or if they do, the xsl processor ignores the sorting or
filtering request.

Would someone please look at the following code snippets of what I was
trying to implement as a parameterized filter and sort xsl stylesheet
and get me pointed in the right direction?  Is their a definitional
limitation in xsl version 1.0 that prevents using parameters at some
of these key points? Book recommendations with sample code would be
appreciated. I prefer an open source solution, not a Microsoft IE 6.0
specific solution.

Thanks - Canopus

===============================
Begin code snippet
===============================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="html" indent="yes" />
<xsl:strip-space elements="*"/>

<!-- big code snip -->

<!-- Set parameters -->

  <!-- Set the external datafilename  -->
    <xsl:variable name"Datafilename">myEventData.xml</xsl:variable>

  <!-- Set filter parameters -->
    <xsl:variable name"FilterOn_Field">EventType</xsl:variable>
    <xsl:variable name"FilterOn_Criteria">Press Release</xsl:variable>

  <!-- Set sort parameters -->
    <xsl:variable name"SortOn_Major_Field">Title</xsl:variable>
    <xsl:variable name"SortOn_Major_OrderBy">ascending</xsl:variable>
    <xsl:variable name"SortOn_Major_DataType">text</xsl:variable>
    <xsl:variable name"SortOn_Minor_Field">EventDate</xsl:variable>
    <xsl:variable name"SortOn_Minor_OrderBy">descending</xsl:variable>
    <xsl:variable name"SortOn_Minor_DataType">number</xsl:variable>


<!-- big code snip -->

<!-- Get the external data table -->
  <xsl:variable name="Events2" select="document($Datafilename)" /> 

  <xsl:for-each select="$Events2/Events/Event">

<!-- Sort the data table -->

  <!-- Major sort -->
    <xsl:sort select="$SortOn_Major_Field"
order='{$SortOn_Major_OrderBy}' data-type="{$SortOn_Major_DataType}"/>

  <!-- Minor sort -->
    <!-- ISO 8601 date field sort -->
    <xsl:sort select="translate($SortOn_Minor_Field, '-', '')"
order='{$SortOn_Minor_OrderBy}' data-type="$SortOn_Minor_DataType"/>

<!-- big code snip -->

<!-- Filter the data table -->
  <xsl:choose>

  <!--  Filter by parameters -->
    <xsl:when test="contains($FilterOnField,'{$FilterOn_Criteria}')">

<!-- big code snip -->

===============================
End code snippet
===============================


transparent
Print
Mail
Like It
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.

.
.

transparent

transparent