[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Fwd: Multiple OR Expression across a node-set

Subject: Re: Fwd: Multiple OR Expression across a node-set
From: "Spencer Tickner" <spencertickner@xxxxxxxxx>
Date: Wed, 29 Nov 2006 15:27:21 -0800
Re:  Fwd: Multiple OR Expression across a node-set
Thank you both very much for your suggestions, I'm looking into the
lookup table now.



On 11/29/06, Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> wrote:

This is a classic case for a lookup table either in your XSLT or in a
separate document (where someone else might help to maintain it :-),
accessed via the document() function.

See http://www.dpawson.co.uk/xsl/sect2/N4995.html for some hints, or
search more broadly for "XSLT lookup tables".

The basic idea is that you construct a little XML that lists your
values; you then traverse this list instead of your input to do your
re-ordering. If you need to structure the list somehow, for example
to group the values (as your sample suggests you might), this is easy
enough to do (since it's XML). This also gives you a chance to
generate something special when values in your list are not
represented in your source file.

The code is more concise than the brute force method as well as
easier to maintain, since both your list of values and their order
are controlled as such, in one place.

I hope that helps,

At 02:19 PM 11/29/2006, you wrote:
>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
>   <id>foo</id>
>   <name>foo</name>
>  <id>bar_archive</id>
>  <name>Bar Archive</name>
>  <id>bar</id>
>  <name>bar</name>
>  <id>foo_archive</id>
>  <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"
><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>
>  <ul>
>  <xsl:apply-templates select="root//view[id='bar']"/>
>  <xsl:apply-templates select="root//view[id='foo']"/>
>  </ul>
><xsl:if test="contains(root//view/id, 'archive')">
>        <p>Here are archive foo bars</p>
>        <blockquote>
>        <xsl:apply-templates select="root//view[id = 'bar_archive']"/>
>        <xsl:apply-templates select="root//view[id = 'foo_archive']"/>
>        </blockquote>
><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

====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.