>Hi,
>
[quoted text clipped - 7 lines]
>
>Sumeet
Sumeet,
If I correctly understand what you are doing then
count(../preceding-sibling::*)+1
should work.
The XPath formula .. selects parent nodes. The preceding-sibling::*
selects all preceding siblings of those parent nodes whatever the name
of those nodes. If you want the count to start at 1 then you add one
to the value that the count() function returns.
Andrew Watt
MVP - InfoPath
KingFu - 28 Sep 2005 15:39 GMT
Hi Andrew,
I've got a similar problem. I have a form that contains questions/answers.
On one of the questions, you could have multiple answers. My HR Dept wants
me to label these answers as (if you were on question 12)
12 a.
12 b.
12 c.
12 d. etc...
I've tried the "count(../preceding-sibiling::*) + 1" and get an error --
The axis is not valid.
count(../-->preceding-sibiling<--::*) + 1
My data source looks similar to this:
myFields
group1
group2
answer to question 12
comments
I'm putting the expression box in group2 for the abc or 123 count of rows.
Does this make sense? Can you help me out?
Bali - 28 Sep 2005 16:14 GMT
Hi,
I was getting the same error so what I did was make the formula just
count(preceding-sibling::*)+1 instead of
count(../preceding-sibling::*)+1.
If you click the edit x-path checkbox below it in the case of
count(preceding-sibling::*)+1 it shows it as
count(../preceding-sibling::*)+1. As Andrew explained thats what we
want but in case of count(../preceding-sibling::*)+1 is written in the
formula field and you click edit x-path then the formula appears as
count(../../preceding-sibling::*)+1.
I don't know how you would take care of the 12 a, 12 b stuff but the
auto numbering worked this way
Sumeet
KingFu - 28 Sep 2005 16:33 GMT
Thanks! That fixed it. At least I'll be able to do a 12.1, 12.2, 12.3
etc.... hopefully that will suffice, as I think the alphabet solution would
be very problematic.
Thanks again,
KingFu