xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cheun N Chong <cnc...@ecs.soton.ac.uk>
Subject URGENT: XML generation errors!!!
Date Fri, 25 Aug 2000 10:44:41 GMT

Dear all,

	I have written the follwing codes, under JBuilder 3, and using
library Java API for XML downloaded from Suns to generate
an XML document:

=======================================================================
import java.io.*;
import org.w3c.dom.*;
import com.sun.xml.tree.*;

public class XMLTicketGenerator {

  public static void main(String[] argv)
     throws IOException, DOMException {

    XmlDocument xmlDoc = new XmlDocument();

    ElementNode tickets = (ElementNode)xmlDoc.createElement("TICKETS");
    ElementNode owner = (ElementNode)xmlDoc.createElement("OWNER");
    ElementNode ticket = (ElementNode)xmlDoc.createElement("TICKET");
    ElementNode issuer = (ElementNode)xmlDoc.createElement("ISSUER");
    ElementNode gameno = (ElementNode)xmlDoc.createElement("GAMENO");
    ElementNode no = (ElementNode)xmlDoc.createElement("NO");

    xmlDoc.appendChild(tickets);            // The root <TICKETS>

    // The contents of the <TICKETS>
    tickets.appendChild(ticket);
    ticket.appendChild(owner);
    ticket.appendChild(issuer);
    ticket.appendChild(gameno);
    ticket.appendChild(no);

    // Put in the element values into the tags
    owner.appendChild(xmlDoc.createTextNode("12345678"));
    issuer.appendChild(xmlDoc.createTextNode("98213412"));
    gameno.appendChild(xmlDoc.createTextNode("3"));
    no.appendChild(xmlDoc.createTextNode("4"));

    xmlDoc.write(new FileOutputStream("ticket.xml"));
    System.exit(0);
    
  }
}
=========================================================================

	The compilation is no problem. However when I tried to run this
program the following error comes out:

AppAccelerator(tm) 1.2.010 for Java (JDK 1.2), x86 version
Copyright (c) 1997-1999 Inprise Corporation. All Rights Reserved.
java.lang.reflect.InvocationTargetException: java.lang.IllegalAccessError: try
to access class com/sun/xml/tree/ParentNode from class XMLTicketGenerator
 	at XMLTicketGenerator.main(XMLTicketGenerator.java:39)
    	at java.lang.reflect.Method.invoke(Native method)
	at com.borland.jbuilder.util.BootStrap.invokeMain(Unknown Source)
	at com.borland.jbuilder.util.BootStrap.main(Unknown Source)

	I referred to book Professional Java Server Programming from Wrox
Press Ltd. pp 299. PLEASE HELP ME. I have been struggling this problem for
ages and now becoming much desperate.

	Thousand thanks for your expertise.
	
	

Best regards,
Cheun Ngen CHONG






Mime
View raw message