473,408 Members | 1,784 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,408 software developers and data experts.

List of pointers to XML nodes

Guy
Hi,

I have an XML file which its content can't be altered as a source. My
solution should be able to produce some kind of pointers (in a seperate file)
to specific nodes (or even attributes\values) in the source XML file.

The source file contains many different namespaces (along with defaults).

The output file later will need to be processed and rewrite sections of the
XML source file by using the pointers ...

What do you think is the best approach for this problem? one solution is to
create a file containing a list of XPath queries - The problem is that XPath
in its nature can't promise unique results (not all of my source nodes has
unique id)

Any suggestions would be really appreciated :-)

Thanks!
Nov 12 '05 #1
1 1198
Hello!
I have an XML file which its content can't be altered as a source. My
solution should be able to produce some kind of pointers (in a seperate file)
to specific nodes (or even attributes\values) in the source XML file.

The source file contains many different namespaces (along with defaults).

The output file later will need to be processed and rewrite sections of the
XML source file by using the pointers ...

What do you think is the best approach for this problem? one solution is to
create a file containing a list of XPath queries - The problem is that XPath
in its nature can't promise unique results (not all of my source nodes has
unique id)


As the source file won't be altered, you can create XPath queries that
match only exactly one node.
I implemented part of XPointer in Javascript and the way I created
unique pointers was:

You start at a specific node. You walk the tree up until you are at the
root node or a node with an ID. As you walk the tree, you count the
siblings of the current node with the same name and save its name and
position.

For example:

<root>
<el id="a">
<a />
<b />
<b>
<c attr="value" />
</b>
</el>
</root>

1. start at attr: @attr
2. go to parent, wich is the only <c/> Element: c/@attr
3. go to parent, wich is the second <b/> Element: b[2]/c/@attr
4. go to parent, wich has an ID: id('a')/b[2]/c/@attr

Namespaces are no problem, the easiest way is to use the same prefixes
everywhere so you just have to save the XPath string. (Mvp.Xml includes
support for XPointer wich allows you to save the Namespaces together
with the path: "xmlns(a=url)xmlns(b=url)xpath1(a:path/b:...)")

--
Pascal Schmitt
Nov 12 '05 #2

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

Similar topics

12
by: Christof Krueger | last post by:
Hello, I'm quite new to C++ so maybe there's something I miss. I write a simple board game. It has a board class. This class has a method that returns the count of pieces a player has on the...
14
by: Dave | last post by:
Hello all, After perusing the Standard, I believe it is true to say that once you insert an element into a std::list<>, its location in memory never changes. This makes a std::list<> ideal for...
5
by: John N. | last post by:
Hi All, Here I have a linked list each containing a char and is double linked. Then I have a pointer to an item in that list which is the current insertion point. In this funtion, the user...
9
by: Goh, Yong Kwang | last post by:
I'm currently doing a project that has a array that supposed to be determined only at runtime. Originally, the prototype I did as a proof of theory (or a quick hack) So one method is to create a...
12
by: Eugen J. Sobchenko | last post by:
Hi! I'm writing function which swaps two arbitrary elements of double-linked list. References to the next element of list must be unique or NULL (even during swap procedure), the same condition...
4
by: JS | last post by:
I have a file called test.c. There I create a pointer to a pcb struct: struct pcb {   void *(*start_routine) (void *);   void *arg;   jmp_buf state;   int    stack; }; ...
3
by: chellappa | last post by:
hi this simple sorting , but it not running...please correect error for sorting using pointer or linked list sorting , i did value sorting in linkedlist please correct error #include<stdio.h>...
9
by: william | last post by:
When implementing Linked list, stack, or trees, we always use pointers to 'link' the nodes. And every node is always defined as: struct node { type data; //data this node contains ... node *...
3
by: maruf.syfullah | last post by:
Consider the following Class definitions: class AClass { int ai1; int ai2; public: CClass* c; AClass(){}
12
by: kalyan | last post by:
Hi, I am using Linux + SysV Shared memory (sorry, but my question is all about offset + pointers and not about linux/IPC) and hence use offset's instead on pointers to store the linked list in...
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?
1
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...
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
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
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.