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

Re: testing element's contents

Subject: Re: testing element's contents
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 03 Oct 2002 17:35:39 -0400
xsl get element
Nate,

At 12:56 PM 10/3/2002, you wrote:
Thanks Wendell. Thinking it over, your simple template
of

> <xsl:template match="p[not(normalize-space(.))]">
>    <xsl:apply-templates/>
> </xsl:template>

will not work, as much as I wish it would, as I am
allowing other elements such as <strong> and <em> and
I could get passed a node set like this

<p><strong>this is bold text</strong></p>

OR this

<p><em>this is bold text</em></p>

For both of those cases, they would need to get
wrapped in a p tag in the output.

The test will work for these cases.


If there are any elements that contain non-whitespace text anywhere inside your p, you'll get a wrapper with this test. You just need to decide whether this describes your requirements accurately. For example, maybe if you had

<p><ul><li>list with one item</li></ul></p>

you'd want to strip that p (whereas the test I've given will create a p in output for this). I dunno, it depends on your source and what you're doing with it.

The real point is if you can characterize your requirement more simply, you can write simpler code. Lots of overlapping tests on the presence of certain element types in certain positions make me nervous: a recipe for incompleteness, confusion and breakage under maintenance. To be avoided if possible.

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.