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

RE: Error trapping in xsl

Subject: RE: Error trapping in xsl
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Thu, 12 Jul 2001 09:27:07 +0100
trapping xsl message
> I'm trying to error trap for empty elements in the xml document
> using xsl:choose & I can't work out the syntax.

First thing is to decide what you mean by "empty" (e.g. is an element empty
if it contains only a comment? Only whitespace text?) A typical meaning is
"has no child nodes", and you can test for that as <xsl:when
test="not(child::node())">.

> Is there a way of error trapping for empty elements globally
> using xsl?


Yes, write a high-priority template rule for them:

<xsl:template match="*[not(child::node())]" priority="10">
  <xsl:message terminate="yes">Element is empty</xsl:message>
</xsl:template>

Of course this will only match an element if it is processed using
<xsl:apply-templates/>

Mike Kay
Software AG


 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.