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

Re: if child element does not exist stop generation

Subject: Re: if child element does not exist stop generation
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 03 May 2005 12:14:16 -0400
xpath element does not exist
At 06:20 AM 5/3/2005, David wrote:
> Hi,
>          You can do this using:
>
><xsl:if test="*[self::length]"> or

That is more easily written as

<xsl:if test="length">

>  or
>
> <xsl:if test="*[name() = 'length']">

Translations from XPath short to long syntax:


"length" is short for
   "child::length"
   (set of 'length' element children of context node)

"*[self::length]" is short for
   "child::*[self::length]
   (set of element children that have a 'length' element on the self axis)

"*[name() = 'length']" is short for
   "child::*[name() = 'length']"
   (set of element children that return 'length' as the result
    of the name() function with an implicit argument of "self::node()")

The xsl:if test works by evaluating the test expression and returning a Boolean; then depending on the Boolean value, the contents of the xsl:if are processed (or not). When the result is not already a Boolean, it is "coerced" using the XPath casting rules. All these tests work because the casting rule for a node-set to a Boolean is that the set is true if it has any members, false if it is empty.

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

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.