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

Re: Conditional display of dates

Subject: Re: Conditional display of dates
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 19 Dec 2001 15:12:11 -0500
xsl template if conditional exists
Hi Katie,

At 02:40 PM 12/19/01, you wrote:
I am trying to display a date. I need to display the "Original Date" if it is returned.

Getting the value of the node will return the value if the node exists, but nothing if it does not.


If a Record with Name = ORIGINAL does not exist or the record with Name = ORIGINAL exists but a date for that record does not, I need to display the "Copy Date" (Name = COPY).

The second case subsumes the first (if the ORIGINAL record does not exist, neither will it have a date), so we need to test only if there is (not) a date.


The template below does this, dropping the ORIGINAL date into a variable (a node-set that either holds the date, or is empty) to make things a bit clearer.

<xsl:template match="RecordSet">
  <xsl:variable name="originalDate"
    select="Record/Name[.='ORIGINAL']/RecordHistorySet/RecordHistroy/Date"/>
  <!-- bind the node to the variable -->

  <!-- we want its value (which is nothing if it doesn't exist) -->
  <xsl:value-of select="$originalDate"/>

  <!-- if it does not exist, we get the other value -->
  <xsl:if test="not($originalDate)">
    <xsl:value-of
      select="Record/Name[.='COPY']/RecordHistorySet/RecordHistroy/Date"/>
  </xsl:if>

</xsl:template>

Does that help? A node-set tests as "true" if there is a node in the node-set, "false" if not.

Cheers,
Wendell



======================================================================
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
======================================================================


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.