Wing replied on the mailing list right after I did. I'll paste his response 
below.

Phil,
a couple of remarks:
1. It appears that the tutorial you were looking at -
http://xmlbeans.apache.org/documentation/tutorial_getstarted.html
- was written for XMLBeans 1.0.x. I have not used 1.0.x. I'm not sure if the 
files referred to in the tutorial are distibuted with 1.0.x or not, but the 
tutorial says, "Start out by creating a new tutorials directory just under your 
XMLBEANS_HOME directory. This will hold the files you create in the course of 
this tutorial." so perhaps you create the files yourself (based on the tutorial 
text).
2. In your example below, you created a new, empty document and didn't populate 
it yet. There is therefore nothing to output. If you look at
http://xmlbeans.apache.org/docs/2.0.0/guide/conGettingStartedwithXMLBeans.html
there is a better example:

public PurchaseOrderDocument createPO()
{
    PurchaseOrderDocument newPODoc = 
PurchaseOrderDocument.Factory.newInstance();
    PurchaseOrder newPO = newPODoc.addNewPurchaseOrder();
    Customer newCustomer = newPO.addNewCustomer();
    newCustomer.setName("Doris Kravitz");
    newCustomer.setAddress("Bellflower, CA");
    return newPODoc;
}
<ns1:purchase-order xmlns:ns1="http://openuri.org/easypo";>
    <ns1:customer>
        <ns1:name>Doris Kravitz</ns1:name>
        <ns1:address>Bellflower, CA</ns1:address>
    </ns1:customer>
</ns1:purchase-order>
Hope that helps,
Wing Yew


From: PhilNad214 PhilNad214 [mailto:philnad...@gmail.com]
Sent: Monday, November 22, 2010 2:58 PM
To: user@xmlbeans.apache.org
Subject: Re: Problems getting started with xmlbeans

Ahhh... ok, I've just been following tutorial right off the front page. Surely 
that needs updating then.

Any idea then where I find this tutorial from Wing Yew Poon? I did a search of 
the XMLBeans site and could not find his name...


On Tue, Nov 23, 2010 at 8:44 AM, Duane Zamrok 
<zam...@cubrc.org<mailto:zam...@cubrc.org>> wrote:
Based upon the schema, your code, and my experience I would expect you to get 
something like the following.

<purchase-order/>

That said, Wing Yew Poon may have hit upon the problem when he mentioned that 
you're looking at a tutorial for 1.0. I advise you to take a look at the 
tutorial he linked and look into using XMLBeans 2.0+ instead of 1.0.

-Duane

From: PhilNad214 PhilNad214 
[mailto:philnad...@gmail.com<mailto:philnad...@gmail.com>]
Sent: Monday, November 22, 2010 2:30 PM

To: user@xmlbeans.apache.org<mailto:user@xmlbeans.apache.org>
Subject: Re: Problems getting started with xmlbeans

Sure (it's simply the one that comes with the distribution)...

<xs:schema
   xmlns:xs="http://www.w3.org/2001/XMLSchema";
   xmlns:po="http://openuri.org/easypo";
   targetNamespace="http://openuri.org/easypo";
   elementFormDefault="qualified">

  <xs:element name="purchase-order">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="customer" type="po:customer"/>
        <xs:element name="date" type="xs:dateTime"/>
        <xs:element name="line-item" type="po:line-item" minOccurs="0" 
maxOccurs="unbounded"/>
        <xs:element name="shipper" type="po:shipper" minOccurs="0" 
maxOccurs="1"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:complexType name="customer">
    <xs:sequence>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="address" type="xs:string"/>
    </xs:sequence>
    <xs:attribute name="age" type="xs:int"/>
    <xs:attribute name="moo" type="xs:int" default="100"/>
    <xs:attribute name="poo" type="xs:int" fixed="200"/>
  </xs:complexType>

  <xs:complexType name="line-item">
    <xs:sequence>
      <xs:element name="description" type="xs:string"/>
      <xs:element name="per-unit-ounces" type="xs:decimal"/>
      <xs:element name="price" type="xs:decimal"/>
      <xs:element name="quantity" type="xs:integer"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="shipper">
    <xs:sequence>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="per-ounce-rate" type="xs:decimal"/>
    </xs:sequence>
  </xs:complexType>

</xs:schema>

On Tue, Nov 23, 2010 at 7:59 AM, Duane Zamrok 
<zam...@cubrc.org<mailto:zam...@cubrc.org>> wrote:
Can you post the schema as well?

Thanks
-Duane

From: PhilNad214 PhilNad214 
[mailto:philnad...@gmail.com<mailto:philnad...@gmail.com>]
Sent: Monday, November 22, 2010 12:17 AM
To: user@xmlbeans.apache.org<mailto:user@xmlbeans.apache.org>
Subject: Re: Problems getting started with xmlbeans

As a followup to this, here is an example:

import org.openuri.easypo.PurchaseOrderDocument;
public class POUpdater {
    POUpdater() {
        PurchaseOrderDocument pod = PurchaseOrderDocument.Factory.newInstance();
        System.out.println(pod.toString());
    }
    public static void main(String args[]) {
        POUpdater po = new POUpdater();
    }
}

... which outputs:

<xml-fragment/>

Shouldn't it output at least an XML structure with at least the basic structure 
of the bean?
On Mon, Nov 22, 2010 at 5:44 PM, PhilNad214 PhilNad214 
<philnad...@gmail.com<mailto:philnad...@gmail.com>> wrote:
Hi, I posted here a couple of weeks ago some basic 'getting started' questions. 
I've just got back to this project and have started using some generated code - 
have created a bean and tried to convert to xml, but all I get is the namespace 
in the xml. I.e it is as if the document.toString() is just showing the top 
node, and not traversing its way through the object to generate all the xml.
Does this sound familiar to anyone? Any suggestions?

The next thing I thought I must be doing something wrong, so I've gone back to 
the getting started tutorial at 
http://xmlbeans.apache.org/documentation/tutorial_getstarted.html
However I cannot for the life of me find a tutorial folder (although I did find 
the easypo.xsd and have successfully generated an easypo.jar). I can't see the 
tutorial files on the apache xmlbeans website anywhere... where on earth do you 
get that from??

Thanks



Reply via email to