Re: [AXIS2][AXIOM] org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR with OMElement created from XML file. HELP ME PLEASE, IMPORTANT!

FILIPPO AGAZZI <[email protected]>
Newsgroups gmane.text.xml.axis.user
Message-ID <CAKLekwkdV4zxfFr0Szzd1Ku4rFmwrz+hOZAQpf7GQpFi60w6eg@mail.gmail.com>
Hi,
I solved the problem. I understand that documentElement has to be imported.
I found ElementHelper#importOMElement(OMElement, OMFactory). With this
method i solved, but i found a problem: instead of passing the object
omFactory (OMFactory omFactory) to importOMElement, i needed to do sth like
this:
OMElement imported = ElementHelper.importOMElement(documentElement,
omFactory.getClass().newInstance())

In this way it worked. I can't explain exacly why, sorry.
Thanks,
Agazzi

2012/10/2 Andreas Veithen <[email protected]>

> Can you please create a bug report for this here:
>
> https://issues.apache.org/jira/browse/AXIOM
>
> Make sure that you mention the exact Axiom version you are using,
> provide the necessary code to reproduce the issue and add the complete
> stack trace.
>
> Andreas
>
> On Mon, Oct 1, 2012 at 12:02 PM, FILIPPO AGAZZI
> <[email protected]> wrote:
> > Hi,
> > i've got a big problem with this: i wanto to do sth like this.
> >
> > FileInputStream policyStream = null;
> >                 try {
> >                     policyStream = new FileInputStream (policy_file);
> >                 } catch (FileNotFoundException e) {
> >                     e.printStackTrace();
> >                 }
> >                 StAXOMBuilder stAXOMBuilder = new
> > StAXOMBuilder(policyStream);
> >                 OMElement documentElement =
> > stAXOMBuilder.getDocumentElement();
> >
> > tnPolicyColl.addChild(documentElement);
> > where tnPolicyColl is an OMElement created with a determinate OMFactory.
> >
> > But i get an error " WRONG_DOCUMENT_ERR: A node is used in a different
> > document than the one that created it." By many searches i understand
> that
> > thw two OMElement must have the same OMFactory. But, the problem is: how
> can
> > i do this, when i need to attach as a child an OMElement created from a
> > source, that is a n XML File? I try also this:
> >
> > FileReader soapFileReader = new FileReader(policy_file);
> >                 XMLStreamReader parser =
> > XMLInputFactory.newInstance().createXMLStreamReader(soapFileReader);
> >                 StAXOMBuilder stAXOMBuilder =  new
> StAXOMBuilder(omFactory,
> > parser);
> >                 OMElement documentElement =
> > stAXOMBuilder.getDocumentElement();
> >
> > But it didn't work. How can i creat an AXIOM object, with a child created
> > from XML File? Please help me, i'm in big trouble!
> > Thanks in advance,
> > Agazzi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.