Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] XMLFragmentMapping only working one way?


Done!

https://bugs.eclipse.org/bugs/show_bug.cgi?id=308041

/Magnus

On Thu, Apr 1, 2010 at 8:57 PM, Blaise Doughan <blaise.doughan@xxxxxxxxxx> wrote:
Hi Magnus,

I have been able to confirm your issue.  The problem only appears to occur when the XPath on the XMLFragmentMapping is self (".").  Could you enter a bug for this issue (I don't mind entering the bug, but customer entered bugs are given higher priority)?

-Blaise

Magnus Heino wrote:

Hi.

I have a XMLFragment mapping, thats only working one way.

My mapping looks something like this;

public XMLDescriptor createMoxySoapMessageDescriptor() {
        XMLDescriptor envelope = this.buildDescriptor(MoxySoapMessage.class);

        envelope.setDefaultRootElement("env:Envelope");
        envelope.setDefaultRootElementType(new QName("env:Envelope"));

        XMLChoiceObjectMapping body = new XMLChoiceObjectMapping();
        body.setAttributeName("body");
        body.addChoiceElement("env:Body", Body.class);
        envelope.addMapping(body);

        return envelope;
    }

    public XMLDescriptor createBodyDescriptor() {
        XMLDescriptor body = this.buildDescriptor(Body.class);

        XMLFragmentMapping node = new XMLFragmentMapping();
        node.setAttributeName("node");
        node.setSetMethodName("setNode");
        node.setGetMethodName("getNode");
        node.setXPath(".");
        body.addMapping(node);

        return body;
    }

import org.w3c.dom.Node;

public class Body {

    protected Node node;

    public Node getNode() {
        return this.node;
    }

    public void setNode(final Node node) {
        this.node = node;
    }

}

If I go from object to xml, I get the right output:

<?xml version="1.0" encoding="UTF-8"?>
   <env:Body>
      <bar:foo xmlns:bar="http://namespace.lantmateriet.se/test">foobar<lmm:foo>inner</lmm:foo>
      </bar:foo>
   </env:Body>
</env:Envelope>

But when I parse this to objects again, I get Body.node as null.... :-P

We are using a custom build of EclipseLink 2.0.1 with https://bugs.eclipse.org/bugs/show_bug.cgi?id=304270 applied.

--

 /Magnus Heino

_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users



--

 /Magnus Heino

Back to the top