You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Jean-Christophe Pazzaglia <Je...@eurecom.fr> on 2004/12/14 20:01:33 UTC

Plugin a DOM element to an xmlbean structure

Copy of Issue 93 (may be useful to others ..)

Dear XmlBeaner,

I find the following behavior rather 'unnatural':

if you do have a DOM element (likely to come from another library
which doesnot use xmlbean) and you want to 'plug'-it with your
XML-Bean structure it does not work 'out of the box' (even if the types
are compatible !?!) and moreover produce non valid XML !

It looks trivial:

let's imagine that you want to add a signature (using xml-security):

myXMLBean.setSignature( SignatureType.Factory.parse(sig.getElement())); 
// compile

this will generate :

<myXMLBean>
<xd:Signature xmlns:xd="http://www.w3.org/2000/09/xmldsig#">
 <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
...
</myXMLBean>

while you expect :

<myXMLBean>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
...
</myXMLBean>

in order to make it you should use

XmlOptions opts = new XmlOptions();
opts.setLoadReplaceDocumentElement(null);

myXMLBean.setSignature( 
SignatureType.Factory.parse(sig.getElement(),xmlopts));


looks rather odd to me ...

jc















---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org