[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] newbie - parameters with/without values??


Subject: [xsl] newbie - parameters with/without values??
From: "Hardy Merrill" <HMerrill@xxxxxxxxxxxxxxxx>
Date: Mon, 04 Oct 2004 11:10:03 -0400

XSLT newbie alert.

I have an xml document with lots of nodes.  I have some fields
(each with its own value) I'd like to use as "search" 
criteria - normally I would pass the field values into the XSL
style sheet as parameters, and just reference the parameters.
But the kicker here is that the parameters may *** or may not ***
have values.  If a parameter has a value, I want to include it in
an XPath select.  If a parameter does NOT have a value, then I
don't want to include that parameter in the XPath select.

I've been trying to use variables to "build" an XPath expression
from the supplied parameters using "if test"s, but I'm not having
much luck since variables can only be given a value once, and their
scope is limited to the block in which they are declared.

Given this XML document: 

<my_document>
   <person>
      <name>Joe</name>
      <gender>Male</gender>
      <city>Boston</city>
  </person>
  <person>
     <name>Janice</name>
     <gender>Female</gender>
     <city>Denver</city>
  </person>
</my_document>

can I build an XSL style sheet to take in parameters "gender" and
"city", which may or may not have values, and *build* an XPath
select expression that will find the right nodes?

I'm sure this is a trivial question, but being a newbie I'm having
trouble with it.

TIA.

Hardy Merrill


Current Thread
Keywords