Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Creating XML where the namespaces differ in different packages
Creating XML where the namespaces differ in different packages [message #898945] Sun, 29 July 2012 06:17 Go to next message
Jean Duteau is currently offline Jean DuteauFriend
Messages: 1
Registered: July 2012
Junior Member
Here is my problem....

I have a package of domain classes that have been annotated and produce my desired XML. I have a package-info.java that defines the default namespace for elements in this package as well as the XHTML namespace since some of the elements produce XHTML.

@javax.xml.bind.annotation.XmlSchema (
	namespace = "default-namespace", elementFormDefault=javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
	xmlns = {@javax.xml.bind.annotation.XmlNs(prefix="xhtml", namespaceURI="xhtml")}
)


This is all working and my unit and integration tests run fine. The XML looks like:
<person xmlns="default-namespace" xmlns:xhtml="xhtml"><address>...</address><summary><xhtml:div><xhtml:p>John Smith of 123 Cranberry Lane</xhtml:p></xhtml:div></summary></person>


In a second package, I have another set of classes that have been annotated and produce desired XML. There is also a package-info.java that defines the default namespace for this package:
@javax.xml.bind.annotation.XmlSchema (namespace = "default-namespace-2", elementFormDefault=javax.xml.bind.annotation.XmlNsForm.QUALIFIED)


This too all works and the XML looks like:
<feed xmlns="default-namespace-2"><entry><title>Person #1</title></entry></feed>


The problem is that I've now added an element from the first package as a field of an object in the second package. It's defined as an Object because it can hold any of the elements from the first package. I also have a string that is mapped to an attribute of the XML so that I can indicate the type:
class Entry {
String title
@XmlPath("resource/@type")
String resourceType
Object resource
}


In my produced XML, I'd like to see is something like this:
<feed xmlns="default-namespace-2"><entry><title>Person #1</title>
    <resource type="person">
        <person xmlns="default-namespace" xmlns:xhtml="xhtml">
            <address>...</address>
            <summary><xhtml:div><xhtml:p>John Smith of 123 Cranberry Lane</xhtml:p></xhtml:div></summary>
        </person>
    </resource>
</entry></feed>


Instead, I get something that I don't think is the same Smile

<feed xmlns="default-namespace-2"><entry><title>Person #1</title>
    <resource type="person" xmlns:ns0="default-namespace" xmlns:xsi="XMLSchema-instance" xsi:type="ns0:person">
        <ns0:address>...</ns0:address>
        <ns0:summary></ns0:summary>
    </person>
</entry></feed>


Obviously I have my mapping wrong. But I'm not sure what the proper mapping would be.

The other thought that I had was if I could somehow call a converter for the Object resource element, I could then inject the proper XML at that point.

Is there an easy way to get the XML that I want?
Re: Creating XML where the namespaces differ in different packages [message #899365 is a reply to message #898945] Tue, 31 July 2012 14:51 Go to previous message
Blaise Doughan is currently offline Blaise DoughanFriend
Messages: 163
Registered: July 2009
Senior Member

Hi Jean,

This appears to be a bug. Would you mind entering one at the following location:

If you could, would you mind attaching your test model. This will help us identify the issue, and supply a fix much faster.

-Blaise
Previous Topic:Problem in Object Relational Mapping with @JoinColumn
Next Topic:Problem with criteria
Goto Forum:
  


Current Time: Thu Apr 25 15:33:50 GMT 2024

Powered by FUDForum. Page generated in 0.03148 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top