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

Re: Determining if the first child is a para element

Subject: Re: Determining if the first child is a para element
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 09 Nov 2000 16:08:11 +0000
xsl if first element
Ken,

At 02:41 PM 11/9/00 +0000, I wrote:

<xsl:if test="child::node()[not(.=normalize-space(.))][1][self::para]">
   ...
</xsl:if>

But of course after seeing Mike Kay's nice test in another thread, I realized a slightly more elegant and efficient version would be


<xsl:if test="child::node()[normalize-space(.)][1][self::para]">
   ...
</xsl:if>

...which reveals further complications (funny how these things are). We have to make sure it's skipped only if it's a whitespace-only _text_ node (not, say, an empty element node). So....

<xsl:if test="child::node()[not(self::text()) or normalize-space(.)][1][self::para]">
...
</xsl:if>


The first predicate evaluates to true if the child node is not a text node or if it has a non-whitespace string value. The second chooses the first of these. The third checks to see whether it's a para element.

For evident reasons, that <xsl:strip-space .../> at the top level will be preferable, if you can use it.

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.