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 <andreas.veit...@gmail.com>

> 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
> <filippo.aga...@studenti.unipr.it> 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: java-user-unsubscr...@axis.apache.org
> For additional commands, e-mail: java-user-h...@axis.apache.org
>
>

Reply via email to