Hello,
My last few posts have been revolving aroung the same problem, and I
still cant solve it and I would be really appreciate if anyone could
spot a problem.
a section of my XML goes like
.....
<parent>
<child>
<grandchild1>
<grandchild2>
<child>
<parent>
/...
I need to describe a numeric link between grandchild elements and the
child elements.
I have been using count(preceding::*) to id the cells numerically:
<xsl:template select="grandchild1|grandchild2">
<MyID>
Child: <xsl:value-of select="count(../preceding::*)"/>
Grandchild: <xsl:value-of select="count(./preceding::*)"/>
</MyID>
</xsl:template>
However, the first grandchild1 element that runs this has the same
count as the child element. (35 and 35). The second grandchild element
that runs is incremented by one as expected, 35 and 36, meaning it
seems 1 too low. The obvious problem is the first counts are returned
the same, negating the idea of unique numeric ID's.
Are these results to be expected? I do not know why/how the ../ and ./
return the same value (surely the ../preceding has come back a node in
that first case and therefore should be -1 of the grandchild1?)
I know a simple fix is just to add one onto all of the grandchilds
(count(./preceding::*)+1) but it seems slight dodgey, i.e. a fix to a
potential problem in my XSL.
I would really appreciate is anyone could help me understand why this
does not work, so that I can fix it properly.
Any help will again be most appreciated.
Thanks, Rob. 3 1721
<ro************@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com... Hello,
My last few posts have been revolving aroung the same problem, and I still cant solve it and I would be really appreciate if anyone could spot a problem.
a section of my XML goes like
.... <parent> <child> <grandchild1> <grandchild2> <child> <parent>
/...
I need to describe a numeric link between grandchild elements and the child elements.
I have been using count(preceding::*) to id the cells numerically:
It is not possible to identify a node uniquely using only one axis.
<xsl:template select="grandchild1|grandchild2"> <MyID> Child: <xsl:value-of select="count(../preceding::*)"/> Grandchild: <xsl:value-of select="count(./preceding::*)"/> </MyID> </xsl:template>
However, the first grandchild1 element that runs this has the same count as the child element. (35 and 35). The second grandchild element that runs is incremented by one as expected, 35 and 36, meaning it seems 1 too low. The obvious problem is the first counts are returned the same, negating the idea of unique numeric ID's.
Are these results to be expected?
Yes.
The "preceding" and "ancestor" axis are non-overlapping and can be thought
of as the X and Y axis in a two-dimensional space (plane).
To quote the XPath 1.0 spec:
"the preceding axis contains all nodes in the same document as the context
node that are before the context node in document order, excluding any
ancestors and excluding attribute nodes and namespace nodes" http://www.w3.org/TR/xpath#axes
I do not know why/how the ../ and ./ return the same value (surely the ../preceding has come back a node in that first case and therefore should be -1 of the grandchild1?)
I know a simple fix is just to add one onto all of the grandchilds (count(./preceding::*)+1) but it seems slight dodgey, i.e. a fix to a potential problem in my XSL.
I would really appreciate is anyone could help me understand why this does not work, so that I can fix it properly.
An unique ID can be constructed taking both the "ancestor" and "preceding"
axis into account and generating a *pair* of numbers.
Another way is to use xsl:number
Cheers,
Dimitre Novatchev Any help will again be most appreciated.
Thanks, Rob.
Another quote from the XPath 1.0 Spec, which describes this topic even more
precisely:
"NOTE: The ancestor, descendant, following, preceding and self axes
partition a document (ignoring attribute and namespace nodes): they do not
overlap and together they contain all the nodes in the document."
Cheers,
Dimitre Novatchev
"Dimitre Novatchev" <x@yyy.com> wrote in message
news:42***********************@authen.white.readfr eenews.net... <ro************@gmail.com> wrote in message news:11**********************@z14g2000cwz.googlegr oups.com... Hello,
My last few posts have been revolving aroung the same problem, and I still cant solve it and I would be really appreciate if anyone could spot a problem.
a section of my XML goes like
.... <parent> <child> <grandchild1> <grandchild2> <child> <parent>
/...
I need to describe a numeric link between grandchild elements and the child elements.
I have been using count(preceding::*) to id the cells numerically:
It is not possible to identify a node uniquely using only one axis.
<xsl:template select="grandchild1|grandchild2"> <MyID> Child: <xsl:value-of select="count(../preceding::*)"/> Grandchild: <xsl:value-of select="count(./preceding::*)"/> </MyID> </xsl:template>
However, the first grandchild1 element that runs this has the same count as the child element. (35 and 35). The second grandchild element that runs is incremented by one as expected, 35 and 36, meaning it seems 1 too low. The obvious problem is the first counts are returned the same, negating the idea of unique numeric ID's.
Are these results to be expected?
Yes.
The "preceding" and "ancestor" axis are non-overlapping and can be thought of as the X and Y axis in a two-dimensional space (plane).
To quote the XPath 1.0 spec:
"the preceding axis contains all nodes in the same document as the context node that are before the context node in document order, excluding any ancestors and excluding attribute nodes and namespace nodes"
http://www.w3.org/TR/xpath#axes
I do not know why/how the ../ and ./ return the same value (surely the ../preceding has come back a node in that first case and therefore should be -1 of the grandchild1?)
I know a simple fix is just to add one onto all of the grandchilds (count(./preceding::*)+1) but it seems slight dodgey, i.e. a fix to a potential problem in my XSL.
I would really appreciate is anyone could help me understand why this does not work, so that I can fix it properly.
An unique ID can be constructed taking both the "ancestor" and "preceding" axis into account and generating a *pair* of numbers.
Another way is to use xsl:number
Cheers, Dimitre Novatchev
Any help will again be most appreciated.
Thanks, Rob.
Ah, that makes real sense. Thanks! That last quote was a good one.
Thanks again, Rob
Dimitre Novatchev wrote: Another quote from the XPath 1.0 Spec, which describes this topic even more precisely:
"NOTE: The ancestor, descendant, following, preceding and self axes partition a document (ignoring attribute and namespace nodes): they do not overlap and together they contain all the nodes in the document."
Cheers, Dimitre Novatchev
"Dimitre Novatchev" <x@yyy.com> wrote in message news:42***********************@authen.white.readfr eenews.net... <ro************@gmail.com> wrote in message news:11**********************@z14g2000cwz.googlegr oups.com... Hello,
My last few posts have been revolving aroung the same problem, and I still cant solve it and I would be really appreciate if anyone could spot a problem.
a section of my XML goes like
.... <parent> <child> <grandchild1> <grandchild2> <child> <parent>
/...
I need to describe a numeric link between grandchild elements and the child elements.
I have been using count(preceding::*) to id the cells numerically:
It is not possible to identify a node uniquely using only one axis.
<xsl:template select="grandchild1|grandchild2"> <MyID> Child: <xsl:value-of select="count(../preceding::*)"/> Grandchild: <xsl:value-of select="count(./preceding::*)"/> </MyID> </xsl:template>
However, the first grandchild1 element that runs this has the same count as the child element. (35 and 35). The second grandchild element that runs is incremented by one as expected, 35 and 36, meaning it seems 1 too low. The obvious problem is the first counts are returned the same, negating the idea of unique numeric ID's.
Are these results to be expected?
Yes.
The "preceding" and "ancestor" axis are non-overlapping and can be thought of as the X and Y axis in a two-dimensional space (plane).
To quote the XPath 1.0 spec:
"the preceding axis contains all nodes in the same document as the context node that are before the context node in document order, excluding any ancestors and excluding attribute nodes and namespace nodes"
http://www.w3.org/TR/xpath#axes
I do not know why/how the ../ and ./ return the same value (surely the ../preceding has come back a node in that first case and therefore should be -1 of the grandchild1?)
I know a simple fix is just to add one onto all of the grandchilds (count(./preceding::*)+1) but it seems slight dodgey, i.e. a fix to a potential problem in my XSL.
I would really appreciate is anyone could help me understand why this does not work, so that I can fix it properly.
An unique ID can be constructed taking both the "ancestor" and "preceding" axis into account and generating a *pair* of numbers.
Another way is to use xsl:number
Cheers, Dimitre Novatchev
Any help will again be most appreciated.
Thanks, Rob.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: hall |
last post by:
Hi.
I've come across someting strange. I was trying to make a for-loop
execute repetadly until the function called inside it does not return
true during the entire loop (see program below).
...
|
by: Piotr Kurpiel |
last post by:
Hello,
I am using MS Access 2003 with VBScript. I have quite strange column names
which are: 1,2,3,4,etc... Data Types of the columns are Yes/No and formats
True/False. The first thing I want to...
|
by: Marc Robitaille |
last post by:
Hello group
I have a strange problem. I have a panel. On this panel, I can drop custom
Textbox that I create at runtime. I have a toolbar on witch a delete button
exist. When I click on this...
|
by: Henk Ernst Blok |
last post by:
Hi Posgres users/developers,
Can anyone explain why PosgreSQL (version 7.4.5 on Linux) does a full
table scan to compute a count(*) on a base table after a vacuum analyze
has been done with no...
|
by: Michael Meckelein |
last post by:
Hello,
I run into trouble move down a selected item in a listbox. The code moving
down the item is the following one:
for (int j = lv.SelectedItems.Count-1; j >=0; j--)
{
ListViewItem...
|
by: Bernard Liang |
last post by:
Consider the following excerpt below, with the included relevant
declarations.
Firstly, the lines marked with **, ***, **** at the beginning are not
supposed to have those stars at the...
|
by: John Kraft |
last post by:
Hello all,
I'm experiencing some, imo, strange behavior with the StreamReader
object I am using in the code below. Summary is that I am downloading
a file from a website and saving it to disk...
|
by: Blackstar |
last post by:
I have a website I am trying to download a file from. This website is
strange in the fact that there is no direct link to the URL of the
file. The way the site works is as follows:
1) Enter in...
|
by: djpaul |
last post by:
Hello,
I have this program and when i want to load pictures it crashes at the form.showdialog()....???
Here it goes:
Private Sub CmbPath_SelectedIndexChanged(ByVal sender As Object, ByVal e As...
|
by: Gilles Ganault |
last post by:
Hello
I'm getting some unwanted result when SELECTing data from an SQLite
database:
======
sql = 'SELECT id FROM master'
rows=list(cursor.execute(sql))
for id in rows:
sql = 'SELECT...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |