• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML Parsing Issue

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The document is not valid.
You can make it valid by changing the DRAWCOMMANDS element definition to be -

Cheers,
Dan
 
Jeremy Quartey
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Dan - I will try that !
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic