categorised product lists: is there a better way?

Subject: categorised product lists: is there a better way?
From: "James Tauber" <jtauber@xxxxxxxxxxx>
Date: Thu, 11 Feb 1999 15:00:22 +0800
I'd like to present a scenario and my current solution and ask if anyone has
    a) a better way of doing under XSL currently
    b) ideas for how XSL could be slightly altered to make this stuff easier

I have an XML file (it doesn't have a prolog so let's assume it's an
external parsed entity) called productlist.xml that lists product
information, along with one or more categories the product fits into:


I'd like to create multiple web pages, one for each category, with a list of
the products in that category.

I have an XML document for each category. The document for the 'foo'
category might look something like this:

<?xml version="1.0"?>
<!DOCTYPE CategoryPage [
<!ENTITY productlist SYSTEM "productlist.xml">
    <Desc>Foos are widgets that are good for fooing.</Desc>

    <ProductSelect Type="foo">

I then have a stylesheet that gets applied to each category document. It
includes the following:

 <xsl:template match="ProductSelect">
        <xsl:when test='.[@Type="foo"]'>
        <xsl:when test='.[@Type="bar"]'>

Now, I don't like this approach for a number of reasons, one of which is
that I have to hardcode the categories in the stylesheet. I wasn't able to
parameterize the above template.

1. Is there a better way of approaching the whole scenario?
2. If this is an ok approach overall, can the above template be
parameterized? Can you say "when you encounter elements of type A with
attribute B=C, then apply templates selecting all D in A that have child
element E with content C" for arbitrary C?
3. If it can't be parameterized, should XSL allow it to be?

On a separate but related note, it would be nice if testing could be on
string sort order as well as equality. XSL already has the notion of
sorting, so it should be quite simple to implement. I like to be able to say
things like "select all A with attribute B > C". My particular application
is with dates. I'm using YYYY-MM-DD so that all that is need is string
sorting, no special knowledge of a date format.

James Tauber

 XSL-List info and archive:

Current Thread