File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes XML Parsing Issue 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 Parsing Issue" Watch "XML Parsing Issue" New topic
Author

XML Parsing Issue

Jeremy Quartey
Greenhorn

Joined: Jan 10, 2002
Posts: 11
Can anyone offer any advice on the following:
I get the error below on running a java project in JBuilder:
Error: problem with parsingElement "<DRAWCOMMANDS>" is not valid because it does not follow the rule, "(START|DRAWSQUARE|DRAWCIRCLE)*".
Document finished

The combined DTD and XML file is
<?xml version = "1.0" standalone = "yes" ?>
<!DOCTYPE DRAWCOMMANDS [
<!ELEMENT DRAWCOMMANDS (START|DRAWSQUARE|DRAWCIRCLE)*>
<!ELEMENT START EMPTY>
<!ELEMENT DRAWSQUARE EMPTY >
<!ELEMENT DRAWCIRCLE EMPTY>
<!ELEMENT DELETEALL EMPTY>
<!ATTLIST DRAWSQUARE
XPOS CDATA #REQUIRED
YPOS CDATA #REQUIRED
>
<!ATTLIST DRAWCIRCLE
XPOS CDATA #REQUIRED
YPOS CDATA #REQUIRED
>
]>
<DRAWCOMMANDS>
<START/>
<DRAWSQUARE XPOS = "14" YPOS = "120"/>
<DRAWCIRCLE XPOS = "20" YPOS = "30"/>
<DRAWCIRCLE XPOS = "120" YPOS = "50"/>
<DRAWSQUARE XPOS = "9" YPOS = "44"/>
<DRAWSQUARE XPOS = "66" YPOS = "130"/>
<DRAWSQUARE XPOS = "80" YPOS = "150"/>
<DELETEALL/>
</DRAWCOMMANDS>
The source code is designed to draw shapes:
if(elementName.equals("DRAWCIRCLE"))
{
//Get attributes
for(int j = 0;j<al.getLength();j++)
{
attributeName = al.getName(j);
attributeValue = al.getValue(j);
if(attributeName.equals("XPOS"))
xPos = Integer.parseInt(attributeValue);
if(attributeName.equals("YPOS"))
yPos = Integer.parseInt(attributeValue);
}
//Draw a circle
df.addCircle(new DrawnCircle(xPos, yPos));
//df is a frame object
}
//Circle encountered
if(elementName.equals("DRAWSQUARE"))
{
//Get attributes
for(int j = 0;j<al.getLength();j++)
{
attributeName = al.getName(j);
attributeValue = al.getValue(j);
if(attributeName.equals("XPOS"))
x = Integer.parseInt(attributeValue);
if(attributeName.equals("YPOS"))
y = Integer.parseInt(attributeValue);
}
//Draw square
df.addSquare(new DrawnSquare(x, y));
df.displaySquaresAndCircles();
}
I am not sure whether the format for START is correct and I still need to make sure DELETALL is correct
Any help will be gratefully accepted
Regards
Jeremy
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1180
The document is not valid.
You can make it valid by changing the DRAWCOMMANDS element definition to be -

Cheers,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Jeremy Quartey
Greenhorn

Joined: Jan 10, 2002
Posts: 11
Thanks Dan - I will try that !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML Parsing Issue