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

JDOM keeping the document valid during insertions...

Hi,

This is my first time with XML, and I am using JDOM, on a Java
client/server application, where the server will store data in XML files
(not using any DBMS). I came across the following problem.

My server class will have a method to receive an XML document, let's say
user.xml, detach its root element and attach to an XML document build in
the server called usersfile.xml. I am using a SAXBuilder to validate
both documents when they are loaded. However I tough of a situation,
where if some unforeseen reason, the new document arrives with an id
(unique), which already exists on the server file, that new document
will be added to the tree, eventually saved/flushed to disk.

But I realized that since master/repository document is already loaded,
the duplicate id, will not become evident until I have to reload the
master document again, which it may be much later, and too late because
the duplicate Id is already in.

So what I am wondering, is how will I be able to ensure that the new
document will not make the master document invalid before it actually
gets inserted on the tree ?

I obviously thought about doing a search in the tree for the Id, and
only proceed with the insertion not found, but that seems to me a bit
hectic... Which raises another question: I've been doing a search in the
tree by getting the children back as a list, and iterating through the
list (Is this the proper way to do so ?). Maybe this is the way to go,
and I am expecting too much of JDOM without using a DBMS ?

Thanks in advance for any help...

--MD.

Jul 20 '05 #1
0 1182

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

Similar topics

1
by: mali djuro | last post by:
Hi all, i try to make xml file with jdom, and also i made xsl file for presenting xml in browser. because of that i need to add processing instuction in xml file .... <?xml-stylesheet...
6
by: mali_djuro | last post by:
Hi all, i used JDOM to create XML file. first, i get data from database and create Document object. in some data i have quotas, so it makes replacment in content of elements. for example: if i...
2
by: Praveen Chhangani | last post by:
Folks, I was wondering if it were possible to convert an org.jdom.doc to an org.w3c.doc document. Essentially what I have is an already parsed document using jdom and I would like to use the...
3
by: Michael | last post by:
hello, I'm a java programmer, and my program will require to parse XML documents and extract data from it, then built a new XML document. Should JDOM or Xerces be the best for me? Please help....
3
by: Bernd Oninger | last post by:
When I run the successfully compiled java source shown at the end I got a runtime error: Exception in thread "main" java.lang.NoClassDefFoundError: org/jdom/Content Where is the missing class ?...
1
by: Son KwonNam | last post by:
Hi~ I usually use JDOM for XML Processing. But, when I tried transforming XSL, I could not find the way to pass parameters to XSLT Processor. "parameters" which are defined in XSL document. (...
2
by: john smith | last post by:
hello, I am having to read an XML document and grab some elements and attributes and then convert that to anther XML document. Which should I use? JAX, DOM, JDOM? I don't really understand...
0
by: kyancy | last post by:
Hello All. We have several XML schemas to describe common component document parts. We then create new XML schemas as necessary that use "xsd:import schemaLocation=whateverLocation.." to include...
2
by: zhengwt | last post by:
I used JDOM.jar to process xml-based document. Recently, I meet such a problem that I can not solve. First, I use the following code generate xml text: Element root = new Element("Root");...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.