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

Re: OR statement

Subject: Re: OR statement
From: david_n_bertoni@xxxxxxxxxx
Date: Tue, 3 Jun 2003 08:43:20 -0700
xsl if or statement



> I'm transforming two (or more) RSS docs into one master xml that I'll be
> using to display on our portal. I'm running into an issue where one of
the
> rss docs uses a date element called <dc:date> and another uses <pubdate>.
> I'd like to transform them so that the final xml document uses only
> <pubdate>.
>
> I've tried a couple of approaches:
> <xsl:if test="(name() = pubdate or dc:date)">
>     <xsl:variable name="cdate" select="name()"/>
>     <xsl:element name="pubdate">
>       <xsl:value-of select="$cdate"/>
>    </xsl:element>
> </xsl:if>
>

This XPath expression is probably what you wanted:

<xsl:if test="name() = 'pubdate' or name() = 'dc:date'">

Note the string literals for the names of the nodes.  Otherwise, they are
considered location paths.

> And
>
> <xsl:choose>
>     <xsl:when test="name() = pubdate">
>         <xsl:element name="pubdate">
>             <xsl:value-of select="node()"/>
>         </xsl:element>
>     </xsl:when>
>     <xsl:when test="name() = dc:date">
>         <xsl:element name="pubdate">
>             <xsl:value-of select="node()"/>
>         </xsl:element>
>     </xsl:when>
>     <xsl:otherwise></xsl:otherwise>
> </xsl:choose>

Again, note the string literals:

<xsl:when test="name() = 'pubdate'">

>
> And I'm not getting the desired results.

You might try this:

<xsl:template match="pubdate | dc:date">
  <pubdate>
    <xsl:value-of select="."/>
  </pubdate>
</xsl:template>

Without seeing more of your stylesheet, it's pretty hard to guess at the
processing model, but I'm assuming the code snippets you posted were inside
an xsl:template instruction.

Dave


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.