This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Error trapping in xsl


Sorry,
To clarify - the XML would look like either:

<book>
        <image_link>marker.gif</image_link>                 <!--CONTAINS
DATA-->
</book>

or

<book>
        <image_link />
<!--EMPTY-->
</book

Thanks,
            Oliver



----- Original Message -----
From: "Michael Kay" <mhkay@iclway.co.uk>
To: <xsl-list@lists.mulberrytech.com>
Sent: Thursday, July 12, 2001 4:27 PM
Subject: RE: [xsl] Error trapping in xsl


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


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]