RE: [xsl] Fwd: Multiple OR Expression across a node-set

Subject: RE: [xsl] Fwd: Multiple OR Expression across a node-set
From: cknell@xxxxxxxxxx
Date: Wed, 29 Nov 2006 15:58:12 -0500
If the document can contain only a specified subset of "id" values, then you are making far too much of this. Consider these templates:

  <xsl:template match="/">
    <xsl:apply-templates />

  <xsl:template match="root">
    <xsl:apply-templates select="view[id='foo']" />
    <xsl:apply-templates select="view[id='bar']" />
    <xsl:apply-templates select="view[id = 'bar_archive']"/>
    <xsl:apply-templates select="view[id = 'foo_archive']"/>

We have a specific order for the output, no matter what the order of the input, and the fact that a specific template rule may not match an element in the input doc has no effect on the output.

If I have misunderstood your problem, please re-state it.

Charles Knell
cknell@xxxxxxxxxx - email

-----Original Message-----
From:     Spencer Tickner <spencertickner@xxxxxxxxx>
Sent:     Wed, 29 Nov 2006 11:19:20 -0800
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  [xsl] Fwd: Multiple OR Expression across a node-set

My Sincerest apologizes, I accidentally sent this to the xml list.

Hi List,

Thanks in advance for the help. I think I left my brain in Cuba, and
cannot seem to figure out this fairly straight forward problem (well
that and secretly hoping someone has a more elegant way of doing

So I have a generated XML

  <name>Bar Archive</name>
  <name>Foo Archive</name>

Issue comes from the fact that every time I get this XML file, the
<view>s are in different, random order. I need them in a specific
order every time. Along with this, sometimes a <view> exists, and
sometimes it doesn't which should be reflected in the output. So far
my XSL looks something like this (I've marked where my if statement is

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="";>

<xsl:template match="/">

<!-- This if statement fails (Value of expression cannot be converted
to a node-set in expression) -->
<xsl:if test="root//view/id = 'foo' | root//view/id = 'bar'">
  <p>Here are the foo bars</p>
  <xsl:apply-templates select="root//view[id='bar']"/>
  <xsl:apply-templates select="root//view[id='foo']"/>

<xsl:if test="contains(root//view/id, 'archive')">
        <p>Here are archive foo bars</p>
        <xsl:apply-templates select="root//view[id = 'bar_archive']"/>
        <xsl:apply-templates select="root//view[id = 'foo_archive']"/>



<xsl:template match="view" priority="5">
<li><xsl:value-of select="name"/></li>

<xsl:template match="view[contains(id, 'archive')]" priority="10">
<p><xsl:value-of select="name"/></p>


Any thoughts would be greatly appreciated. (PS - I am stuck with 1.0)

Thanks you,

Spencer Tickner

Current Thread