473,407 Members | 2,359 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,407 software developers and data experts.

How to find out the position of a element in the XML Document

Hi,

I have a requirement where I am transforming a XML into a html using
an XSL. I need to create a object for the each and every occurrence of
an element named "tgroup" in the xml. Also I need to assign a unique id
for this object based upon the its occurence in the xml document. (note:
the unique id should not be assigned depeneding upon its position with
respect to the parent element but with respect to its number of
occurence in the document).

This tgroup element can occur at n number of places in the xml document
and it not limited to occur within another element.

For example:

it is not only a child of a particular element but it can be a child of
other elements in the document tooo.

<root>
...
<A1>
<tgroup></tgroup>
.................
<A2>
<tgroup></tgroup>
<B1>
<tgroup></tgroup>
<B2>
<tgroup></tgroup>
<B3>
<tgroup></tgroup>

</root>

I have multiple xsl files which is use to transform this. So for each
and every occurence of a <tgroup> i need to create an object tag in the
target html with a unique id which I want as "tablecontrol1"
"tablecontrol2" "tablecontrol3" etcc..

Here 1, 2, 3 are the position of this element in the entire document. I
used the position() function of XPath to find out but it give the
position of the element in the context node only and not the position of
this element in the entire docuemnt.

Is there a way where I can find out the position of an element in the
entire document.

thanks
-Eshrath


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
1 2553
> I have a requirement where I am transforming a XML into a html using
an XSL. I need to create a object for the each and every occurrence of
an element named "tgroup" in the xml. Also I need to assign a unique id
for this object based upon the its occurence in the xml document. (note:
the unique id should not be assigned depeneding upon its position with
respect to the parent element but with respect to its number of
occurence in the document).


Hi,

Not sure it is the best method, but I think this should work:

<xsl:value-of select="count(preceding::tgroup)+1"/>

regards,

--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #2

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

Similar topics

3
by: Markus Ernst | last post by:
Hello Reading the follwing document: http://www.w3.org/TR/WD-positioning-970131#In-flow it seems very clear that position:relative should be relative to the parent element. So in the following...
1
by: Knut | last post by:
Hello everybody. This is my first attempt at Javascript, something that is long overdue. But please bear that in mind, and have mercy (= My question is simple: I'm doing a dropdown menu...
10
by: Danny | last post by:
How can I get the coordinates of the mouse cursor in Mozilla browsers as well as Opera and IE6? I'm struggling to understand how to capture mouse movement events with Mozilla/Netscape/Firefox and...
1
by: Dave Hammond | last post by:
I have an html element (a link) with an onclick handler which opens a popup window, and would like to position that window at the coordinates where the element appears on the page. I have...
2
by: ted | last post by:
Hi, Was wondering if it's possible to find the left position of a table cell if the cell is created dynamically. I have a table with a single cell. When a button is clicked, I'd like to add...
17
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I find the size of a browser window?...
4
by: Petra Meier | last post by:
Hi, I use the common code to determine the position of an element getTop = function(o){ var nTop = null; if(o){ do{ nTop += o.offsetTop;
5
iam_clint
by: iam_clint | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta...
4
by: HoangTuanSu | last post by:
I have just got a javascript code from my friend. I've modified it for my purpose but a problem happens. First, here's my code html <body> <table align="center" width="60%" height="100%"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
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
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
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.