This boils down to the fact that you don't have a <shipper> global element, so 
if you want to parse the value of a Shipper type (which  I believe is you 
intention based on the code snippet you wrote), then your XML needs to look 
like:
 
<xml-fragment>

  <name>ZipShip</name>

  <per-ounce-rate>0.74</per-ounce-rate>

</xml-fragment>

 
See the "Parsing an XML Fragment" thread for explanation on how to parse 
document fragments (documents that don't have a global Schema element as root): 
http://mail-archives.apache.org/mod_mbox/xmlbeans-user/200804.mbox/browser
 
Radu
________________________________

From: Frank Rossol [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 30, 2008 2:16 AM
To: [email protected]
Subject: Set does duplicate Element



        Hello,

         

        i have a strange problem using Typed Nodes set method.

        I used the easypo.xsd schema from the samples directory to create the 
java.classes.

        Now I tried to import a Shipper-Node to the PurchaseOrderDocument using 
the following code:

         

        String podocpath = "<path to easypo.xml> ";

        podoc = PurchaseOrderDocument.Factory.parse(podocpath);

        String shipperpath = "<path to shipper.xml> ";

        Shipper shipper = Shipper.Factory.parse(new File(shipperpath));

        podoc.getPurchaseOrder().setShipper(shipper);

        String test = podoc.toString();

         

        easypo.xml 

         

        <?xml version='1.0' encoding='iso8859-1'?>

        <purchase-order xmlns="http://openuri.org/easypo";>

            <customer>

                <name>Gladys Kravitz</name>

                <address>Anytown, PA</address>

            </customer>

            <date>2003-01-07T14:16:00-05:00</date>

            <line-item>

                <description>Burnham's Celestial Handbook, Vol 1</description>

                <per-unit-ounces>5</per-unit-ounces>

                <price>21.79</price>

                <quantity>2</quantity>

            </line-item>

            <line-item>

                <description>Burnham's Celestial Handbook, Vol 2</description>

                <per-unit-ounces>5</per-unit-ounces>

                <price>19.89</price>

                <quantity>2</quantity>

            </line-item>

            <shipper>

                <name>ZipShip</name>

                <per-ounce-rate>0.74</per-ounce-rate>

            </shipper>

        </purchase-order>

         

         

        shipper.xml

        <?xml version='1.0' encoding='iso8859-1'?>

        <shipper xmlns="http://openuri.org/easypo";>

          <name>ZipShip</name>

          <per-ounce-rate>0.74</per-ounce-rate>

        </shipper>

         

        the toString() function produced the following output:

         

        <purchase-order xmlns="http://openuri.org/easypo";>

          <customer>

            <name>Gladys Kravitz</name>

            <address>Anytown, PA</address>

          </customer>

          <date>2003-01-07T14:16:00-05:00</date>

          <line-item>

            <description>Burnham's Celestial Handbook, Vol 1</description>

            <per-unit-ounces>5</per-unit-ounces>

            <price>21.79</price>

            <quantity>2</quantity>

          </line-item>

          <line-item>

            <description>Burnham's Celestial Handbook, Vol 2</description>

            <per-unit-ounces>5</per-unit-ounces>

            <price>19.89</price>

            <quantity>2</quantity>

          </line-item>

          <shipper>

            <shipper>

              <name>ZipShip</name>

              <per-ounce-rate>0.74</per-ounce-rate>

            </shipper>

          </shipper>

        </purchase-order>

        Any Suggestions why the shipper-Node is not replaced.

         

        Thanks Frank

         

         

        Frank Rossol
        Dipl. Inform. (FH) 

        
        otten|software GmbH
        Röntgenring 7
        D-40878 Ratingen
        
        Amtsgericht Düsseldorf HRB 55584
        Geschäftsführer: Dr.Marcus Otten
        
        Tel +49 2102 30964-0
        Fax +49 2102 30964-29
        [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 
        www.otten-software.de <http://www.otten-software.de/> 

         


Notice:  This email message, together with any attachments, may contain 
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated 
entities,  that may be confidential,  proprietary,  copyrighted  and/or legally 
privileged, and is intended solely for the use of the individual or entity 
named in this message. If you are not the intended recipient, and have received 
this message in error, please immediately return this by email and then delete 
it.

Reply via email to