xsl-list
[Top] [All Lists]

Re: Re: Identifying Existence of Attributes

2003-03-17 09:28:01
I'm hoping there's a more elegant way to do it using a one-line 
apply-templates or call-templates instead of three or more if
statement

lines.   I've been pretty successful in getting most of the
conditional
code

out of my templates.  This is one of the areas I haven't spent much
time 
trying to figured out yet...


In many cases it is possible to have a conditional expression in one
line (e.g. conditional selection of strings, conditional selection of a
nodeset, conditional selection of arguments of an operation, etc, etc.)
-- it depends on what you want to do if the condition is true or false,
which you haven't shown to us.



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL





From: "Dimitre Novatchev" <dnovatchev(_at_)yahoo(_dot_)com>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Re: Identifying Existence of Attributes
Date: Sat, 15 Mar 2003 09:43:37 +0100

<balajeec(_at_)mastek(_dot_)com> wrote in message

news:551A143C7FC0F64FA508178F55A7E01902FE2412(_at_)ind-spz7exh002(_dot_)mastek(_dot_)com(_dot_)(_dot_)(_dot_)
Hi ,
I have an element by the name
<Text>
I want to check whether the current <Text> node has the attribute
by the
name
"indent"
defined in it.
How can i do it.??


Just test for @indent

e.g.:

<xsl:if test="@indent ">
  <!-- do something -->
</xsl:if>


Translated in English the above means: "if the current node has an 
attribute
named 'indent' do something".

The test does not depend on whether the current node is named
"Text",
because you said this is already a known fact.


In case you want to check that both the current node is named "Text"
and
it
has an attribute named "indent", the XPath expression that returns
the

truth
value of this fact is:

self::Text and @indent





__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com

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



<Prev in Thread] Current Thread [Next in Thread>