xsl-list
[Top] [All Lists]

Re: Trouble selecting appropriate node-set depending on parameters

2004-09-27 22:57:55
Hi Jarno,

Thanks!  That's exactly what I was looking for.

Cheers,

-Travis

----- Original Message ----- 
From: <Jarno(_dot_)Elovirta(_at_)nokia(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Monday, September 27, 2004 9:41 PM
Subject: RE: [xsl] Trouble selecting appropriate node-set depending on
parameters


Hi,

I'm writing a small xsl stylesheet to select a subset of
nodes from an xml
document.  The important part looks like this...

<xsl:param name="PRODUCTGROUP" />
<xsl:param name="PLATFORM"  />
<xsl:param name="ITEM" />

<xsl:for-each select="/store/productGroup[(_at_)type =
$PRODUCTGROUP]/platform[(_at_)type=$PLATFORM]/item[(_at_)type=$ITEM]">

etc..


What happens is I pass in the values of productgroup,
platform and item with
php.  I can then retrieve a list of all items the attributes
of which match
the criteria.  This seems to work fine, the only trouble is,
I'd like in
some cases to be able to choose all items, regardless of
attributes, like
so...

<xsl:for-each select="/store/productGroup/platform/item">

or any combination, like so...

<xsl:for-each
select="/store/productGroup/platform[(_at_)type=$PLATFORM]/item">

I guess I'm a bit unclear how to be able to choose between multiple
node-sets, depending on the whether or not one of the
parameters is set.
I've been searching for info on this most of the afternoon,
but can't seem
to find much.

If @type always has a non-zero-length value, then

<xsl:for-each select="/store/productGroup[(_at_)type=$PRODUCTGROUP or
$PRODUCTGROUP=""]/platform[(_at_)type=$PLATFORM or 
$PLATFORM=""]/item[(_at_)type=$ITEM
or $ITEM=""]">

would work.

Cheers,

Jarno - Nick Sentience: March 2003 Mix

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 9/10/2004