|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.
Hi, I have read the documentation about namespace resolution many times now (http://wiki.eclipse.org/Using_Workbench_(ELUG)#How_to_Configure_XML_Schema_Namespace), 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="http://www.w3.org/2001/XMLSchema" xmlns="http://www.foo.com/bar/baz" targetNamespace="http://www.foo.com/bar/baz" elementFormDefault="qualified" attributeFormDefault="unqualified"> My document is like this: <Address xmlns='http://www.foo.com/bar/baz' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='...' ><LineOne>101 Main Street</LineOne><LineTwo>Apt 514</LineTwo> <City>Malibu</City> <State>CA</State> <Country>USA</Country> <PostalCode>90914-2938</PostalCode> </Address> 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 http://www.foo.com/bar/baz 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. Isthere a way to configure things so that marshalling does not use the prefix?Thanks! --Polly
Back to the top