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

RE: OR statement

Subject: RE: OR statement
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Tue, 3 Jun 2003 10:58:09 -0500
xsl if or operator
> 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)">

There are a few problems with this...

1) The "or" operator is meant to connect two boolean expressions,
   so instead of
      name() = pubdate or dc:date
   you want
      name() = pubdate or name() = dc:date

2) pubdate needs to be quoted; otherwise it is interpreted as
   "the string value of the child element of . whose name is 'pubdate'"
   so you want
      name() = 'pubdate' or name() = 'dc:date'
   or
      self::pubdate or self::dc:date

   The latter form has the benefit of doing proper namespace checking.
   (Assuming you've declared the dc namespace in your stylesheet.)

> Anyone know how I can easily check if it's the <dc:date> or 
> the <pubdate>
> and tranform it to a <pubdate> if it's the <dc:date> (while inside a
> <xsl:for-each>)?

You were on the right track...

<xsl:if test="self::pubdate or self::dc:date">
  <xsl:element name="pubdate">
    <xsl:value-of select="." />
  </xsl:element>
</xsl:if>

Lars


 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.