We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Processing 1.0 and proXML
Page Index Toggle Pages: 1
Processing 1.0 and proXML (Read 231 times)
Processing 1.0 and proXML
Jun 10th, 2009, 6:46am
 
Hey everyone,
I have taken this script out of the examples folder inside the proxml folder. It should work therefore I thought, but when executing I get this error:  "The type XMLElement ist ambigious"

Code:
/*
this is a more complex example demonstrating the possibilities
of proxml. In the example the user can draw ellipses that are saved
into a xml file. This file is loaded on the next start of the program.
If there exists an xml file it is loaded and the
content is drawn as ellipses. Otherwise the xml element is created.
*/

import proxml.*;


//to store the background after painting an ellipse
PImage back;

//xml element to store and load the drawn ellipses
pXMLElement ellipses;
XMLInOut xmlInOut;

int xPos = 0;
int yPos = 0;

void setup(){
 size(400,400);
 smooth();
 background(255);

 //load ellipses from file if it exists
 xmlInOut = new XMLInOut(this);
 try{
   xmlInOut.loadElement("ellipse.xml");
 }catch(Exception e){
   //if the xml file could not be loaded it has to be created
   xmlEvent(new XMLElement("ellipses"));
 }
}

void xmlEvent(XMLElement element){
 ellipses = element;
 initEllipses();
   //initialise PImage for background
 back = new PImage(width,height);
 loadPixels();
 back.pixels = pixels;
}

void draw(){
}

//draw all ellipses saved in the xml file
void initEllipses(){
 ellipses.printElementTree(" ");
 XMLElement ellipse;
 XMLElement position;
 XMLElement size;
 
 for(int i = 0; i < ellipses.countChildren();i++){
   ellipse = ellipses.getChild(i);
   position = ellipse.getChild(0);
   size = ellipse.getChild(1);
   ellipse(
     position.getIntAttribute("xPos"),
     position.getIntAttribute("yPos"),
     size.getFloatAttribute("Xsize"),
     size.getFloatAttribute("Ysize")
   );
 }
}

void mousePressed(){
 xPos = mouseX;
 yPos = mouseY;
}

void mouseDragged(){
 background(back);
 ellipse(xPos,yPos,abs(xPos-mouseX),abs(yPos-mouseY));
}

void mouseReleased(){
 XMLElement ellipse = new XMLElement("ellipse");
 ellipses.addChild(ellipse);
 XMLElement position = new XMLElement("position");
 position.addAttribute("xPos",xPos);
 position.addAttribute("yPos",yPos);
 ellipse.addChild(position);
 XMLElement size = new XMLElement("size");
 size.addAttribute("Xsize",abs(xPos-mouseX));
 size.addAttribute("Ysize",abs(yPos-mouseY));
 ellipse.addChild(size);
 xmlInOut.saveElement(ellipses,"ellipse.xml");
 loadPixels();
 back.pixels = pixels;
}


I read trough several threads here and there they said one has to to write
Code:
proxml.XMLElement ellipses; 


instead of the originial
Code:
XMLElement ellipses; 



when doing so, i get this error: "Cannot find class or typed named proxml.XMLElement"

so - does anyone has an idea why this does not work???
I'll be glad for some help Smiley
Re: Processing 1.0 and proXML
Reply #1 - Jun 10th, 2009, 7:01am
 
The error message means that it can see more than one class called XMLElement I added the following import and it worked for me. Cheesy

Code:

import proxml.*;
import proxml.XMLElement;



Page Index Toggle Pages: 1