You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Pa...@ipaustralia.gov.au on 2004/09/24 08:12:52 UTC
compilation help
Hi ,
I am trying to compile and run sample code provided in XMLbeans release
download(easypo one.). I have installed xml beans at C:\xmlbeans-1.0.3. and
created environment variable called XMLBEANS_HOME . I have also updated
path .
When I compile easypo by using scomp it is compiling fine and generating a
jar file .My next step is to create a class file called POHandler(i am
copying and pasting the code available on page
http://xmlbeans.apache.org/docs/guide/conGettingStartedwithXMLBeans.html),
When I try to compile this class I got this error. package
org.openuri.easypo does not exist. Some more erros are:
compile:
[javac] Compiling 1 source file to C:\build\tmeform\ejb
[javac] C:\cvs_src\POHandler.java:24: cannot resolve symbol
[javac] symbol : class PurchaseOrderDocument
[javac] location: class
au.gov.ipaustralia.tmeform.ejb.TMeFormParsingEjb
[javac] PurchaseOrderDocument poDoc =
PurchaseOrderDocument.Factory.parse(po);
[javac] ^
[javac] C:\cvs_src\POHandler.java:24: package PurchaseOrderDocum
nt does not exist
[javac] PurchaseOrderDocument poDoc =
PurchaseOrderDocument.Factory.parse(po);
[javac] ^
[javac] C:\cvs_src\POHandler.java:30: cannot resolve symbol
[javac] symbol : class PurchaseOrder
[javac] location: class
au.gov.ipaustralia.tmeform.ejb.TMeFormParsingEjb
[javac] PurchaseOrder po = poDoc.getPurchaseOrder();
[javac] ^
[javac] C:\cvs_src\POHandler.java:30: po is already defined in p
intItems(java.io.File)
[javac] PurchaseOrder po = poDoc.getPurchaseOrder();
[javac] ^
[javac] C:\cvs_src\POHandler.java:40: cannot resolve symbol
[javac] symbol : class LineItem
[javac] location: class POHandler
[javac] LineItem[] lineitems = po.getLineItemArray();
[javac] ^
[javac] C:\cvs_src\POHandler.java:58: inconvertible types
[javac] found : java.lang.String
[javac] required: int
[javac] numberOfItems += lineitems[j].getQuantity();
[javac] ^
Please help.
regards,
--Pankaj
***********************
package docs.xmlbeans;
import java.io.File;
import org.apache.xmlbeans.*;
import org.openuri.easypo.PurchaseOrderDocument;
import org.openuri.easypo.PurchaseOrder;
import org.openuri.easypo.LineItem;
public class POHandler
{
public static void printItems(File po) throws Exception
{
/*
* All XMLBeans schema types provide a nested Factory class you can
* use to bind XML to the type, or to create new instances of the
type.
* Note that a "Document" type such as this one is an XMLBeans
* construct for representing a global element. It provides a way
* for you to get and set the contents of the entire element.
*
* Also, note that the parse method will only succeed if the
* XML you're parsing appears to conform to the schema.
*/
PurchaseOrderDocument poDoc =
PurchaseOrderDocument.Factory.parse(po);
/*
* The PurchaseOrder type represents the purchase-order element's
* complex type.
*/
PurchaseOrder po = poDoc.getPurchaseOrder();
/*
* When an element may occur more than once as a child element,
* the schema compiler will generate methods that refer to an
* array of that element. The line-item element is defined with
* a maxOccurs attribute value of "unbounded", meaning that
* it may occur as many times in an instance document as needed.
* So there are methods such as getLineItemArray and
setLineItemArray.
*/
LineItem[] lineitems = po.getLineItemArray();
System.out.println("Purchase order has " + lineitems.length + "
line items.");
double totalAmount = 0.0;
int numberOfItems = 0;
/*
* Loop through the line-item elements, using generated accessors
to
* get values for child elements such a description, quantity, and
* price.
*/
for (int j = 0; j < lineitems.length; j++)
{
System.out.println(" Line item: " + j);
System.out.println(
lineitems[j].getDescription());
System.out.println(" Quantity: " +
lineitems[j].getQuantity());
System.out.println(" Price: " + lineitems[j].getPrice());
numberOfItems += lineitems[j].getQuantity();
totalAmount += lineitems[j].getPrice() *
lineitems[j].getQuantity();
}
System.out.println("Total items: " + numberOfItems);
System.out.println("Total amount: " + totalAmount);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org