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

Re: checking if an attribute exists

Subject: Re: checking if an attribute exists
From: Oskar Werewka <ow5@xxxxxxxxxxxxxx>
Date: Mon, 11 Jun 2001 20:36:09 +0200
xslt if attribute exists

Thank you. It is working now.


> This i very simple question:
>
> <element attribute="...">Value</element>
>
> How can I check if the "attribute" attribute is defined?

I'll use the following as an example because it will be easier to discuss
(i.e. I won't have to talk about the element element or the attribute
attribute):

<car color="...">Value</car>

If you want to know whether a given car element has a color attribute set,
then <xsl:if test="@color"></xsl:if> in a template rule for car will check
for this.

I was fighting test="@color" for one hour, but I was in a wrong node ;->



If, on the other hand, by "defined" you mean that you want to check whether
color was declared as an attribute for the car element, you can't, because
attribute list declarations happen in the DTD, and an XSLT processor has no
way of knowing what's in the DTD.

The input to an XSLT processor is an in-memory representation of a document
known as a source tree that was constructed with the help of an XML parser.
This parser may have looked at the DTD, but once the source tree is created,
the parser's job is done, and the XSLT processor has no way of knowing what
effect a DTD may have had on the tree's construction.

Bob DuCharme            www.snee.com/bob             <bob@
snee.com>      see http://www.snee.com/bob/xsltquickly for
info on new book "XSLT Quickly" from Manning Publications.



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



--


Kamera wideo Sony, 5000 zl
wygraj w konkursie eMarketu i Onet.pl [ http://konkursy.onet.pl/emarket ]


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.