Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] MOXy: Marshalling with no namespace prefix?

Hi Polly,

EclipseLink doesn't currently support the default namespace for marshalling. We require a prefix for any namespace that's used. However, there is already a work item to add support for this, so it will be coming in the near future.



I have read the documentation about namespace resolution many times now
but I am still unsure of how to do what I want to do.  Please bear with me
if this is a stupid question.

My schema is defined like this:

<xsd:schema xmlns:xsd="";
	targetNamespace=""; elementFormDefault="qualified"

My document is like this:
<Address xmlns=''
xsi:schemaLocation='...' >
<LineOne>101 Main Street</LineOne>
   <LineTwo>Apt 514</LineTwo>


It appears that when unmarshalling the document, EclipseLink searches for an
entry in the XMLContext that contains both the namespace and the element
name.  So to tell EclipseLink the association between the namespace URL and
the element, I found through trial and error to configure EclipseLink using
these options:

Namespace URL 	                   Prefix 	 Declare 	ns1 	      true

Then my document unmarshalls correctly and everything's great!

Unfortunately, I found that when I marshall the object back out, all the
elements have the namespace prefix, like "ns1:Address".   The documentation
regarding the Prefix field says:

"When the EclipseLink runtime marshalls (writes) an object to an XML
document, it uses the namespace prefixes you specify here."

But what if I don't want to use the prefix?  We defined the target namespace
so that our documents do not have to use the prefix and can be cleaner.  Is
there a way to configure things so that marshalling does not use the prefix?

Back to the top