aspose file tools*
The moose likes XML and Related Technologies and the fly likes XML Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML Query" Watch "XML Query" New topic
Author

XML Query

Jeremy Quartey
Greenhorn

Joined: Jan 10, 2002
Posts: 11
I have tried to provide a DTD which describes the following data:
When a user accesses an application within a local network, data is generated which describes their access, this includes:
the user name;
the time when they started their access;
the files that were accessed;
the time when they concluded their access;
the name of the computer which they used to carry out the access
I have also provided an example of the language which it describes.
My question is does the format look correct
<?xml version = "1.0" encoding ="UTF-8" standalone = "yes" ?>
<!DOCTYPE ACCESSLOGFILE[
< !ELEMENT ACCESSLOG LOGELEMENTS (USERNAME, STARTTIME, FILE+, ENDTIME, COMPUTERNAME)>
< !ELEMENT USERNAME (#PCDATA) >
< !ELEMENT STARTTIME (#PCDATA) >
< !ELEMENT FILE (#PCDATA) >
< !ELEMENT ENDTIME (#PCDATA) >
< !ELEMENT COMPUTERNAME (#PCDATA) >
<!ATTLIST USERNAME CDATA #REQUIRED
USERNAME user_ID #REQUIRED >
>
<!ATTLIST STARTTIME CDATA #REQUIRED
>
<!ATTLIST FILE CDATA #REQUIRED
>
<!ATTLIST ENDTIME CDATA #REQUIRED
>
<!ATTLIST COMPUTERNAME CDATA #REQUIRED
>
]>
<ACCESSLOGFILE >
< LOGELEMENTS >
< USERNAME > < USERNAME >
< STARTTIME > < STARTTIME >
< FILE > < FILE >
< ENDTIME > < ENDTIME >
< COMPUTERNAME > < COMPUTERNAME >
< /LOGELEMENTS >
</ACCESSLOGFILE >

Any comments would be very gratefully accepted
Regards
J
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Jeremy,
First, the syntax used for the inline DTD was wrong and next time, please format your code by using the CODE button (see Instant UBB Code) under the Add Reply button in the post window.
The correct syntax should read:

Regarding the structure itself, it seems that the LOGELEMENTS element is redundant with the ACCESSLOGFILE root element.
If you would like later to consolidate your access log files into one using the same DTD, it seems better to allow multiple LOGELEMENTS to appear by changing one line in the DTD:

Another thing would be to take some time to decide how data should be stored : attribute or text. Then try to have a consistent structure that follows your rules.
Hope this helps
Jeremy Quartey
Greenhorn

Joined: Jan 10, 2002
Posts: 11
Benoit
Thanks for your help. I tried your suggested syntax for the inline DTD but still received the following system.out in the message pane of JBuilder 4 while testing it:

"Document started
Problem starting XML processor "EMPTY", "ANY", or '(' expected. "
Any ideas what this message means ?

Regards
J
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Jeremy,
My fault, I should I tried parsing the file :roll:
The following line was indeed wrong:

It should be replaced by:

Hence, obviously, my suggestion should read:

Cheers
 
wood burning stoves
 
subject: XML Query