开发者

Storing XML Files in Database

I have to create a des开发者_StackOverflow中文版ktop application in Java 6. Program should be able to communicate with other system using XML files (sending/receiving). Every single XML file is connected with its XSD, tags describing its content, username and status of the document. Application should provide such functionality as searching, modyfying etc. XML content.

The question is: how should I store all these information retaining logical connections?

I came up with an idea to store it using XML database - BaseX. In other words, storing XML files with information connected to them in one big XML (database) file.

Sample database:

<?XML VERSION="1.0"?>

<mySampleRecord id="1">

<XMLcontent> // Content of XML file (...) </XMLcontent>

<XMLschema> // Content of XSD file (...) </XMLschema>

<tags>j2ee java xml</tags>

<username>File Owner</username>

<status>received</status>

</mySampleRecord>

<mySampleRecord id="2">

<XMLcontent> // Content of XML file (...) </XMLcontent>

<XMLschema> // Content of XSD file (...) </XMLschema>

<tags>doc xls mdb</tags>

<username>Admin</username>

<status>sent</status>

</mySampleRecord>

I was also wondering if it's possible BaseX to read <XMLContent> node and then treat its content as XML enabling me to perform XQuery operations.

Hope its understandable ;)

Thanks for any hints and suggestions.


Didn't quite get it. :)

So you want to store several XMLFiles with the corresponding schema in another XML file?

Why do that? Just treat each XML file individually. Have them as .xml files inside your .jar .. thus each client can get access to it.

cheers


If I understood you correctly you should create table SAMPLE_RECORD with fields id (PK) user_name status

then create table TAG with fields record_id (FK to table record) tag

Create class SampleRecord Now write code that parse XML and create instances of SampleRecord. Then implement logic that stores collection of SampleRecord in DB and reads it from there. You can either use ORM or just old good plain JDBC.

That's it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜