Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 questions (Java/XML)

Status
Not open for further replies.

dakkardaemor

Programmer
Apr 24, 2005
7
IT
1st question:

I've a HTML form, I must create an XML fragment from it and add this piece of XML to an existing XML file, that I use as a simple database.
For example:
Code:
<database>
<record id="0">
<name>john</name>
<phone>234</phone>
</record>
<record id="1">
<name>Henry</name>
<phone>564</phone>
</record>
</database>
[/code>

So with my HTML form I fill name and phone and I must add the new record to my XML file. I can use "specific" code, but must be general (for many types of simple XML databases.

2nd question

How can I validate the added record with a given XML schema?
The schema can validate a single record, and not the entire XML database.
 
Using XML as a "database" is madness - its a relatively expensive operation using XML parsers, and in general XML does not lend itself well to the kind of function a standard relational database will provide.


--------------------------------------------------
Free Database Connection Pooling Software
 
yes, I think you're right, but I must do this thing... so if you have some suggestions or tips I'm really happy to hear... well... read them! ^_^

 
Yeah thanks, so you suggest me to use a parser... well clearly I thought about it... but with what? a JSP? ...and how can I apply a given schema file to an XML fragment obtained by an HTML form?

...and after this validation how can I add it to a given XML file that works as a "simple" database?

I don't want that you write this code for me, but more precise directions on the best way to do it and don't take a "wrong way"... All my project is made with Java :), but I'm unsure on some "points" and this is the last one (I hope!)

Thank you anyway friend!
 
Can I ask a question, dakkardaemoer? What are the requirements that dictate that you MUST use XML as a 'simple' database? If someone from 'above' has mandated exactly this, then fair enough (unless you can persuade them against it), but maybe there is a better alternate which meets your requirements.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Well... Ok I start to explain "the thing" from begin :)

I've 2 input:
- a XML Schema file, that describes the fields of a single record (this file it's used to validate the form, as I said with 1 of my questions above)
- an XSL file used as stylesheet for a "view" of a single record

I must do the following things:
1- upload the input files ((and this works))
2- generate the HTML form (used to add/modify/view/cancel a single record) from the uploaded XSD file ((and this is quite working, with XSLT, I must consider only a fundamental subset of XML Schema))
3- add/modify operations are quite similar. I must create a XML fragment from my HTML form... I know a bit about the use of DOM, but I'd like to receive suggestions to accomply this job. (the other of my questions above)
4- cancel is really simple (load the file with parser and search the desired node, and delete it :p)
5- view, I thing I must apply the given XSL to an XML fragment and send it to the browser (well... Maybe I need a tip on this one... I'm able to apply a XSL to a complete XML file not a fragment)

Ok? I hope you understand my poor English!

I'm interested to the XSD/XML/XSL part, the database is just a simple application, I can use a "real" database, but it's not my focus... ;-)

Thank you in advance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top