| 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: 1121
|
|
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 !
|
 |
 |
|
|
subject: XML Parsing Issue
|
|
|