473,486 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Counting self axes

Hi,

This may be a stupid question, but if you count a self axe will it
always return 1?

For example:

count(self::*)

and

count(../../this_path/overhere/self::*)

Any help would be much appreciated. My XSL transformation is doing a
couple of strange things and I am not 100% sure on this. (plus it be
more efficient to put + 1 when required!)

Thanks, Rob.

Aug 1 '05 #1
5 1266
Hi,
Tempore 20:28:59, die Monday 01 August 2005 AD, hinc in foro {comp.text.xml} scripsit <ro************@gmail.com>:
This may be a stupid question, but if you count a self axe will it
always return 1?


No, not always.
This will only return 1 if the context node is a node which has a qname: i.e. elements and processing instructions. Not all XSLT - implementations follow this though: AltovaXSLT allows attributes as well.

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Deserta faciunt et innovationem appelant
Aug 1 '05 #2
Thanks!, Rob.
Joris Gillis wrote:
Hi,
Tempore 20:28:59, die Monday 01 August 2005 AD, hinc in foro {comp.text.xml} scripsit <ro************@gmail.com>:
This may be a stupid question, but if you count a self axe will it
always return 1?


No, not always.
This will only return 1 if the context node is a node which has a qname: i.e. elements and processing instructions. Not all XSLT - implementations follow this though: AltovaXSLT allows attributes as well.

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Deserta faciunt et innovationem appelant


Aug 1 '05 #3
In article <11**********************@g44g2000cwa.googlegroups .com>,
<ro************@gmail.com> wrote:
This may be a stupid question, but if you count a self axe will it
always return 1?


The self axis of a node always contains exactly one node (the node
itself). So count(.../self::node()) will always return 1, if "..."
selects a single node.

self::* on the other hand only matches elements, because the principal
node type for the self axis is element. So if "..." selects a single
element, count(.../self::*) will return 1. If it selects a single
node of some other type, it will return 0.

-- Richard
Aug 1 '05 #4
Thanks, thats really helped to clear it up.

Thanks, Rob

Aug 2 '05 #5

"Joris Gillis" <ro**@pandora.be> wrote in message
news:op***************@news.pandora.be...
Hi,
Tempore 20:28:59, die Monday 01 August 2005 AD, hinc in foro
{comp.text.xml} scripsit <ro************@gmail.com>:
This may be a stupid question, but if you count a self axe will it
always return 1?
No, not always.
This will only return 1 if the context node is a node which has a qname:
i.e. elements and processing instructions.


That's not correct.

1) self::* selects the current node only if it is an element.; not if it
is a processing instruction.

If the current node is a processing instruction, then the following
expression (using the "self" axis) selects the current node:

2) self::processing-instruction()

3) Regardless of the type of the node, it is selected by:

self::node()

Cheers,
Dimitre Novatchev

Not all XSLT - implementations follow this though: AltovaXSLT allows
attributes as well.

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Deserta faciunt et innovationem appelant

Aug 2 '05 #6

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

Similar topics

4
6823
by: Travers Naran | last post by:
Here's the basic idea. I have a dictionary of substrings (the substrings stored as keys). I have a list of strings. I want to find out, for each word in the dictionary, how many times the...
4
6554
by: Victor Engmark | last post by:
When looking for a method to fetch unique elements and counting the number of occurences of each of them, I found quite a lot of gross examples of complex XSL. But after realizing the subtle...
1
2372
by: Vijay | last post by:
Hi Can anybody explain what self::* means in Xpath. I understand that "self" means the context node itself and * means any node type. So I thought self::* meant all the child nodes of context,...
9
1861
by: David Poundall | last post by:
I have a thread class and I want to be able to track its usage within an application. FYI the class launches aplications in their own thread when the 'launch' method is called. That works OK ...
0
1128
by: Steven Bethard | last post by:
I feel like I must be reinventing the wheel here, so I figured I'd post to see what other people have been doing for this. In general, I love the optparse interface, but it doesn't do any checks...
14
2062
by: Dan | last post by:
Is this discouraged?: for line in open(filename): <do something with line> That is, should I do this instead?: fileptr = open(filename) for line in fileptr: <do something with line>
0
932
by: Andreas Huesgen | last post by:
Hello, I have a question refering python's reference counting/garbage collection in combination with thrown exceptions. I'm very new to this mailinglist, so I hope, that this question has not...
1
4631
by: Eric Holbrook | last post by:
I'm using matplotlib to generate (and save) plots of bandwidth data from simulation logs. Since the simulations are of varying lengths, i need a way to scale the axes so that every 100,000 points...
27
2062
by: Mark | last post by:
Hi all, I have a scenario where I have a list like this: User Score 1 0 1 1 1 5 2 3 2 1
0
7105
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
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
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
7341
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
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4870
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...
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.