|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
How to marshall objects using default namespace?Hi,
I see that the bug "ADD SUPPORT FOR THE DEFAULT NAMESPACE" (https://bugs.eclipse.org/bugs/show_bug.cgi?id=236051) has been implemented. How do I make use of this new feature? Currently I have the schemas defined like this in the workbench: Target Namespace: http://www.foo.com/bar/baz Prefix: ns1 Declare: true This will output the "ns1" namespace prefix in front of my elements. But when I change Declare to "false", I get the usual error message about not finding the root element: [Exception [EclipseLink-25008] (Eclipse Persistence Services - 1.0 (Build SNAPSHOT - 20080618)): org.eclipse.persistence.exceptions.XMLMarshalException Exception Description: A descriptor with default root element {http://www.foo.com/bar/baz}Address was not found in the project] I am also unable to set the namespace prefix to "" in the workbench. How does one use this default namespace? Thanks! --Polly |
|
|
Re: How to marshall objects using default namespace?The support for the default namespace has been added into the runtime, but hasn't been implemented in the Mapping Workbench yet. Please see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236491 to track the support in the workbench. In order to make use of this before the mapping workbench feature is completed, you would have to either manually modify your mappings xml file, or modify your mappings in code during an afterloads. In the mapping .xml file, you'd want to add your default namespace to any namespace resolvers in the document: <namespace-resolver>
<namespaces>
...
</namespaces>
<default-namespace-uri>http://www.foo.com/bar/baz</default-namespace-uri>
</namespace-resolver>
Then you'd want to modify the xpath of any mapping or default-root-element that was currently prefix-qualified, to remove the prefix:
<default-root-element>ns1:Description</default-root-element>
becomes:
<default-root-element>Description</default-root-element>
<attribute-mapping xsi:type="xml-direct-mapping">
...
<field name="ns1:CityName/text()" xsi:type="node"/>
</attribute-mapping>
becomes:
<attribute-mapping xsi:type="xml-direct-mapping">
...
<field name="CityName/text()" xsi:type="node"/>
</attribute-mapping>
Hope that helps,
-Matt
amphoras wrote:
Hi, I see that the bug "ADD SUPPORT FOR THE DEFAULT NAMESPACE" (https://bugs.eclipse.org/bugs/show_bug.cgi?id=236051) has been implemented. How do I make use of this new feature? Currently I have the schemas defined like this in the workbench: Target Namespace: http://www.foo.com/bar/baz Prefix: ns1 Declare: true This will output the "ns1" namespace prefix in front of my elements. But when I change Declare to "false", I get the usual error message about not finding the root element: [Exception [EclipseLink-25008] (Eclipse Persistence Services - 1.0 (Build SNAPSHOT - 20080618)): org.eclipse.persistence.exceptions.XMLMarshalException Exception Description: A descriptor with default root element {http://www.foo.com/bar/baz}Address was not found in the project] I am also unable to set the namespace prefix to "" in the workbench. How does one use this default namespace? Thanks! --Polly _______________________________________________ eclipselink-users mailing list eclipselink-users@... https://dev.eclipse.org/mailman/listinfo/eclipselink-users |
|
|
Re: How to marshall objects using default namespace?Hi Matt,
Ah, ok. Thanks for the XML snippets. I'll give it a try! :) Thanks, Polly
|
|
|
Re: How to marshall objects using default namespace?Hi Matt,
Just thought I'd let you know the result. I tried what you said here by changing my project.xml this way: 1. Set namespace-resolver to this (I don't have other namespaces): <namespace-resolver> <namespaces/> <default-namespace-uri>http://http://www.foo.com/bar/baz</default-namespace-uri> </namespace-resolver> 2. Removed all instances of "ns1:". And it works!! Thank you so much! :) --Polly
|
| Free embeddable forum powered by Nabble | Forum Help |