xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Paransky <ap...@standardset.com>
Subject Wrapping xml-fragment into AnyDocument looses runtime type information
Date Fri, 19 Mar 2004 03:44:06 GMT
I posted this message on the Bea newsgroup, but I think most of the 
action is here anyway...

I would like to store a fragment of xml in a database. However, to stay 
XML compatible, I don't want to have <xml-fragment> tags. To avoid this, 
I attempt to "wrap" the xml-fragment inside of an AnyDocument using the 
following code:

private static AnyDocument wrap(final XmlObject o) {
  final AnyDocument anyDocument = AnyDocument.Factory.newInstance();
  final AnyDocument.Any any = anyDocument.addNewAny();
  any.set(o);
  return anyDocument;
}

The problem, is that somehow my runtime type is getting lost after the 
wrapping occurs.

Here is how the data looks BEFORE wrap (o.save()):

<?xml version="1.0" encoding="UTF-8"?>
<xml-fragment
  xsi:type="loc:AddTermRequestT"
  xmlns:loc="http://www.overture.com/service/common/local" 
<http://www.overture.com/service/common/local>
  xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" 
<http://schemas.xmlsoap.org/soap/envelope/>
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
<http://schemas.xmlsoap.org/soap/encoding/>
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
<http://www.w3.org/2001/XMLSchema>
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
<http://www.w3.org/2001/XMLSchema-instance>
  xmlns:dis="http://www.overture.com/service/display" 
<http://www.overture.com/service/display>
 > <http://www.overture.com/service/display>
  <loc:accountId>1123223ZZZ</loc:accountId>
  <loc:term>dog</loc:term>
  <loc:price>0.55</loc:price>
</xml-fragment>

Note that in the above XML the runtime type is set as: 
xsi:type="loc:AddTermRequestT

Here is how the data looks after I attempt to wrap it with AnyDocument:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:any
  xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" 
<http://schemas.xmlsoap.org/soap/envelope/>
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
<http://www.w3.org/2001/XMLSchema-instance>
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
<http://schemas.xmlsoap.org/soap/encoding/>
  xmlns:dis="http://www.overture.com/service/display" 
<http://www.overture.com/service/display>
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
<http://www.w3.org/2001/XMLSchema>
  xmlns:loc="http://www.overture.com/service/common/local" 
<http://www.overture.com/service/common/local>
  > <http://www.overture.com/service/common/local>
  <loc:accountId>1123223ZZZ</loc:accountId>
  <loc:term>dog</loc:term>
  <loc:price>0.55</loc:price>
</xsd:any>

The runtime type (xsi:type="loc:AddTermRequestT) is gone and it's not 
clear how to parse the new XML.

Am I doing something wrong? Why does the runtime type go away? Is this 
the correct way to "warp" some fragment with a valid document.

Again, the intent here is to store something to the database that a 
different tool can understand later.

Thanks.

-- 
-AP_
http://www.myprofiles.com/member/profile/apara_personal
http://www.myprofiles.com/member/profile/apara_business



- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Mime
View raw message