Hi there. I do realize this is a
java forum and not an XML forum but I thought I might just see if anybody can help me nonetheless. I am trying to parse thru XML files to extract certain detail from said files. The following is a snippet of the file type that I am parsing:
<useractions>
<mapaction>
<action_id>z03</action_id>
<feature_id>D21</feature_id>
<action_time>1088421430234</action_time>
</mapaction>
<layer>
<frame_number>1</frame_number>
<feature_id>D21</feature_id>
</layer>
<mapaction>
<action_id>z02</action_id>
<feature_id>D21</feature_id>
......
</useractions>.
and so on. I have the header and dtd set up as the file seems to be parsed correctly up till a certain point at least. It parses the first <mapaction></mapaction> and <layer></layer> perfectly. However I get the following error as soon as my code encounters the second <mapaction> tag. The error is as follows:
org.xml.sax.SAXParseException: Element "useractions" does not allow "mapaction" here. I realize that it is most likely the way I have defined my dtd. The dtd I am using is set up as follows:
<?xml version='1.0' encoding='utf-8'?>
<!-- DTD for a simple "XML recording". -->
<!ELEMENT useractions (mapaction+, layer+)>
<!ELEMENT mapaction (action_id, feature_id*, action_time)>
<!ELEMENT action_id (#PCDATA)>
<!ELEMENT feature_id (#PCDATA | feature_id)*>
<!ELEMENT action_time (#PCDATA)>
<!ELEMENT layer (frame_number, feature_id*)>
<!ELEMENT frame_number (#PCDATA)>
I cannot see anything wrong here as useractions is defined to contain a series of mapaction elements and layer elements. However the program returns
an error as soon as the second mapaction is reached. Can anyone offer any suggestions please. Thanks Joe