Hi folks,
I'm an absolute newbie at XSL. Books are on order from Amazon, but I
have three days to get a prototype up and running for my department
head (because, since I've done web development with ASP, PHP, and
ColdFusion "of course" I should be able to whip this off with no
problem -- or so I'm told...) I've stumbled my way through most of
it -- thanks to the archives here and other web resources -- but now
I'm hitting a wall over something that's probably stupid and
obvious. Please be patient with me!
I have an ASP form which is passing two values to my xsl -- let's say
for this example "food" and "fruit". I need an alphabetized list of
all items that match those criteria. So;
apple
banana
orange
is the result I want.
Here's the XML:
<catalog>
<entry>
<word>orange</word>
<category type="food" subcat="fruit"/>
<info>
<serving_size>...</serving_size>
<preparation>...</preparation>
</info>
</entry>
<entry>
<word>spinach</word>
<category type="food" subcat="vegetable"/>
<info>
<serving_size>...</serving_size>
<preparation>...</preparation>
</info>
</entry>
<entry>
<word>apple</word>
<category type="food" subcat="fruit"/>
<info>
<serving_size>...</serving_size>
<preparation>...</preparation>
</info>
</entry>
<entry>
<word>kale</word>
<category type="food" subcat="vegetable"/>
<info>
<serving_size>...</serving_size>
<preparation>...</preparation>
</info>
</entry>
<entry>
<word>endive</word>
<category type="food" subcat="vegetable"/>
<info>
<serving_size>...</serving_size>
<preparation>...</preparation>
</info>
</entry>
<entry>
<word>banana</word>
<category type="food" subcat="fruit"/>
<info>
<serving_size>...</serving_size>
<preparation>...</preparation>
</info>
</entry>
</catalog>
This gives me the correct items, but not in alphabetical order:
<xsl:param name="param1"/>
<xsl:param name="param2"/>
<xsl:template match="catalog/entry">
<xsl:if test="category[(_at_)type=$param1] and
category[(_at_)subcat=$param2]">
<xsl:for-each select="word">
<xsl:sort/>
<xsl:apply-templates/><br/>
</xsl:for-each>
</xsl:if>
</xsl:template>
Returns this list:
orange
apple
banana
This one gives me an alphabetized list, but of all the items, not
just the ones that match the params:
<xsl:template match="catalog">
<xsl:if test="entry/category[(_at_)type=$param1] and
entry/category[(_at_)subcat=$param2]">
<xsl:for-each select="entry/word">
<xsl:sort/>
<xsl:apply-templates/><br/>
</xsl:for-each>
</xsl:if>
</xsl:template>
Returns this:
apple
banana
endive
kale
orange
spinach
What am I doing wrong, and why do these two versions, which to my
rank amateur brain look like they should be the same, return such
different results?
Thanks much for any explanation and assistance you can give me.
M. Casey
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.410 / Virus Database: 268.17.12/655 - Release Date: 1/28/2007
--~------------------------------------------------------------------
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>
--~--