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

RE: [xsl]


Subject: RE: [xsl] <xsl:for-each select="$myvar">
From: "Andrew Welch" <awelch@xxxxxxxxxxxxxxx>
Date: Wed, 19 Jun 2002 16:06:09 +0100

Bill,

I think you want to display certain nodes depending on a parameter from
the user.  Say, for example, you want to display only DEC machines.  To
do this pass the 'search string' to your stylesheet (how you do this
depends on your setup, but its well documented) and then within you
stylesheet you will need something like:

<xsl:param name="searchString"/>
 
<xsl:template match="/">
<xsl:for-each select="item[manufacturer = $searchString]">
  <xsl:apply-templates/>
</xsl:for-each>
</xsl:template>

This will then only apply-templates to the <item>'s with a
<manufacturer> of whatever is in your $searchString.

is this any good?

cheers
andrew






-----Original Message-----
From: William S. [mailto:wstan@xxxxxxxxx]
Sent: 19 June 2002 14:58
To: xsl-list
Subject: [xsl] <xsl:for-each select="$myvar">


I am trying to do the operation as described in the subject
line but am getting "Sablotron Error (48): 
expression is not a node set".

The value of the variable is "item" which is the same as if  
I used "<xsl:for-each select="item">" So why
doesnt this work?

What I had hoped to do with this is allow the user to
have control what is displayed in an XML file. For
instance with the XML file below I would like to display
only DEC machines, or only Compaq, or only IBM.

XML file sample...

<?xml version="1.0" ?>

<collection>
        <intro>My Computer Collection</intro>
<item>
        <manufacturer>DEC</manufacturer>
        <model>MicroVAX 3100-30</model>
        <opsys>OpenVMS 5.5-2</opsys>
        <cpu>25MHz</cpu>
        <memory>unknown</memory>
        <enclosure>BA42-B</enclosure>
        <notes>none</notes>
</item>

<item>
        <manufacturer>DEC</manufacturer>
        <model>MicroVAX II</model>
        <opsys>OpenVMS 5.5-2</opsys>
        <cpu>KA630</cpu>
        <memory>unknown</memory>
        <enclosure>BA23 rackmount</enclosure>
        <notes>This is my first VAX which I hope to get running
        with OSU (=DECthreads)</notes>
</item>
 . . . . and so on...

By the way, I am not too sure the XML file is formatted very
well. This is just a test setup. Can anyone suggest a better way to
do it? I can't seem to see anything in the archives. I am
using php with Sablotron and doing this all on the server end.

Thank you,
-- 
Bill
Amsterdam, NL

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list





---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.350 / Virus Database: 196 - Release Date: 17/04/2002
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.350 / Virus Database: 196 - Release Date: 17/04/2002
 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords
xml