473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Counting an elment where its attribut equals to true

Hello,

I have this template :
<root>
<categorie>
<poste att = 'true'>
.....
</poste>
<poste att = 'false'>
.....
</poste>
<poste att = 'true'>
.....
</poste>
</categorie>
<categorie>
................
...............
</categorie>
</root>

In my XSL, I like to check if all poste's attribut equal to false, I
will output a text message "there is no poste"
else output the poste where attribut equal to true.

Thanks for your support.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
5 1692
So what is your question?

=====
Cheers,

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

"khaled Hajjar" <el******@look.ca> wrote in message
news:3f*********************@news.frii.net...
Hello,

I have this template :
<root>
<categorie>
<poste att = 'true'>
.....
</poste>
<poste att = 'false'>
.....
</poste>
<poste att = 'true'>
.....
</poste>
</categorie>
<categorie>
................
...............
</categorie>
</root>

In my XSL, I like to check if all poste's attribut equal to false, I
will output a text message "there is no poste"
else output the poste where attribut equal to true.

Thanks for your support.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 20 '05 #2


In my XSL, what do I put to have these in the output file? :

If all poste's attribut equal to false, will output a text message
"there is no poste"
else output value element of poste, where attribut equal to true.

In other way, How can I know in my poste elements that I have at least
one element its attribut equal to true?

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
> In other way, How can I know in my poste elements that I have at least
one element its attribut equal to true?


The condition to test for is:

/root/categorie/poste[@att = 'true']
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
Jul 20 '05 #4
Thanks for your answer, but it still some thing missing.
Sorry about my english.

These way, it works element by element, but I need before I parsed all
poste elements, I like to know if there is a poste element have an
attribut 'true'.

If the attribut of all poste elments are false, I will output the
message 'there no poste'

I will give an example :
<categorie>
<poste att='true'>
comments about poste a
</poste>
<poste att='false'>
comments about poste b
</poste>
<poste att='false'>
comments about poste c
</poste>
</categorie>

If I use this test, I will get 'comments about poste a'. This is a
correct, but my question, if I set the first attribut to false, I want
the output is 'there no poste' one time for the 3 poste element.

Another, I like to have a condition before start parsing the poste
elements, that tell me in these all poste element, there is at least one
attribut to true.

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5
In article <3f*********************@news.frii.net>,
khaled Hajjar <el******@look.ca> wrote:

% These way, it works element by element, but I need before I parsed all
% poste elements, I like to know if there is a poste element have an
% attribut 'true'.

You need to use a conditional test.
<xsl:choose>
<xsl:when test='/categorie/poste[@att = "true"]'>
<xsl:value-of select='/categorie/poste[@att = "true"]'/>
</xsl:when>
<xsl:otherwise>There is no poste with att set to 'true'.</xsl:otherwise>
</xsl:choose>

If you need to handle cases where more than one poste has att set to
true differently, you could have

<xsl:apply-templates match='/categorie/poste[@att = "true"]'/>

instead of using xsl:value-of. If it's too slow, you could put
the select expression in a variable.
--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: emma middlebrook | last post by:
Hi Having difficulty getting myself clear on how a type's operator== fits in with Object.Equals. Let's just consider reference types. The default operator== tests for object identity...
17
by: Zeng | last post by:
I'm trying to comparing 2 objects (pointer to object) to see if they are the "same" as each other. Here is what the definition of being the "same" object type for both objects, object 1, ...
4
by: Kurt | last post by:
Wouldn't you agree all of the follwoing should produce the same result? r = (o1 == o2); r = (o2 == o1); r = object.Equals(o1, o2); r = object.Equals(o2, o1); r = (o1.Equals(o2)); r =...
12
by: Rubbrecht Philippe | last post by:
Hi there, According to documentation I read the ArrayList.IndexOf method uses the Object.Equals method to loop through the items in its list and locate the first index of an item that returns...
8
by: Kenneth Baltrinic | last post by:
When one overrides the Equals() method of an object, one is supposed to override GetHashCode() as well and this makes good sense. But I have seen lots of people who do this and do not override the...
3
by: Marc Robitaille | last post by:
Hello, I have this Field attribut class and a Client class that uses this Attribut Class <AttributeUsage(AttributeTargets.Property)_ Public Class Field Inherits Attribute Private _FieldName...
17
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
What is the difference of == and Object.Equals() If I want to query werther to pointers are pointing to same instance, do I use == or Objects.Equals? foo a,b; if ( a == b ) ... or if...
10
by: r035198x | last post by:
The Object class has five non final methods namely equals, hashCode, toString, clone, and finalize. These were designed to be overridden according to specific general contracts. Other classes that...
7
by: =?Utf-8?B?QWxleCBDb2hu?= | last post by:
In C++, there is an easy technique to provide an overloaded Equals() method. A straightforward translation to C# causes a stack overflow. Why does b.Equals(ba) in the snippet below not understand...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.