[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: kenb@xxxxxxxxxxx
Date: Thu, 9 Nov 2000 14:11:26 -0800
xsl if first
Wendell,
	The whitespace only issue hadn't occurred to me.  Since the
XML input comes from a third party, I think I'll have to use your
more complex test.  Thanks.

Ken

-----Original Message-----
From: Wendell Piez [mailto:wapiez@xxxxxxxxxxxxxxxx]
Sent: Thursday, November 09, 2000 6:42 AM
To: xsl-list@xxxxxxxxxxxxxxxx
Subject: Re: Determining if the first child is a para element


Ken,

At 10:15 AM 11/9/00 +0000, Jeni wrote:
>So, to test whether the first child node of
>the current node is an element, use:
>
>   <xsl:if test="child::node()[1][self::*]">
>      ...
>   </xsl:if>

Also be careful in this case that you have accounted for the possibility of 
any whitespace-only text nodes. So, for example, if your document read:

<CHAPTER>
   <para>Here's my first child element, a para.</para>
...
</CHAPTER>

Jeni's test above will fail on account of the whitespace-only text node 
preceding the para element (it contains a carriage return and two space 
characters).

Adjust for this by saying

<xsl:strip-space elements="CHAPTER"/>

at the top level, or altering your test (somewhat horribly) to:

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

Jeni's test for whether the first element child is a para is still good, of 
course, since the whitespace-only nodes won't come into play then.

Regards,
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


 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.