xml-xmlbeans-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Vasilik" <eric...@bea.com>
Subject RE: toString gives me <xml-fragment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></xml-fragment>
Date Tue, 27 Jul 2004 17:19:21 GMT
Factory.newInstance does not create elements per se.  It creates a new
XML document/fragment (think DOM) which can contain a schema type
instance.  So, if you have a global PurchaseOrder element defined in
your schema, and you do something like:
You will, effectively,  get back a document fragment which is capable of
halding the contents of a PurchaseOrder.  The important thing to know
where is that a PurchaseOrder type does *not* include the
<purchaseOrder> element, just the contents of the element.
This element is part of the type definition of the
PurchaseOrderDocument.  If you were to create a PurchaseOrderDocument
You would get an empty document capable of holding a
PurchaseOrderDocument, which can contain a PurchaseOrder element which,
in turn, could contain a PurchaseOrder instance.
The reason you are seeing the <xml-fragment/> being saved out is that
this is the serialization of an empty document.  If you want the element
printed, then create a PurchaseOrderDocument and then create the element
by adding the PurchaseOrder:
    PurchaseOrderDocument  poDoc =
    PurchaseOrderDocument.PurchaseOrder  po = poDoc.addPurchaseOrder();
    poDoc.save( System.out );
- Eric
-----Original Message-----
From: Sateesh.Kumar@iflexsolutions.com
Sent: Tuesday, July 27, 2004 8:52 AM
To: xmlbeans-dev@xml.apache.org
Subject: toString gives me <xml-fragment
I have created an xml element with xml beans using Factory.newinstance()
rather than creating the element by adding it to its parent. Now when I
say element.toString() it is returning me the string <xml-fragment
            I want the element name to be printed rather than the
Please advise.

View raw message