users@jaxb.java.net

Re: how to setup jaxb marshaller to generate the namespaces at the root node.

From: Srinivasan Chikkala <srinivasan.chikkala_at_Sun.COM>
Date: Wed, 08 Jun 2005 12:26:35 -0700

Hi jon,

Thanks for the pointer. I actually looked at the documentation in the
jwsdp1.5 at jaxb/docs/vendorProperties.html which mentioned class
com.sun.xml.bind.marshaller.NamespacePrefixMapper and the method
(getPreferredPrefix ) that should be implemented for mapping namespace
URIs to prefixes which is not sufficient for my purpose, but the way the
example namespace-prefix override the method
"getPreDeclaredNamespaceUris()" is what I have to do to get the
namespaces at the root node, but as it mentioned in this method's
documentation in the example, this will not be useful if I don't know
the uris in advance and in my case, I don't know the uri's in advance
as I just unmarshall the xml document that I receive, modify it and
marshall it back to xml document

thanks,
-chikkala

gold wrote:

> there's an example that comes with the jwsdp (jaxb/samples directory,
> i think) called something like the namespace mapping example. i've
> used that example to do just what you want. even better, you can use
> whatever prefix you want, not just 'ns2'.
>
> jon
>
> Srinivasan Chikkala wrote:
>
>> When I marshall the jaxb model that contains the elements with
>> attributes of type javax.xml.namespaces.QName, the namespace prefix
>> and the namespace uri is generated locally in the parent element. Is
>> there a way to tell the marshaller to generate all the namespaces in
>> the root element of the xml document?
>>
>> I am getting the marshalled xml like
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>> <services-info version="1.0" xmlns="http://java.sun.com/xml/ns/ns1">
>> <services component="true">
>> <provide endpoint-name="MyServiceEndpoint"
>> interface-name="ns2:MyInterface" service-name="ns2:MyService"
>> xmlns:ns2="http://www.example.org/myservice.wsdl"/>
>> </services>
>> </services-info>
>>
>> I want to get the xml like this
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>> <services-info version="1.0"
>> xmlns="http://java.sun.com/xml/ns/my/ns1"
>> xmlns:ns2="http://www.example.org/myservice.wsdl >
>> <services component="true">
>> <provide endpoint-name="MyServiceEndpoint"
>> interface-name="ns2:MyInterface" service-name="ns2:MyService" />
>> </services>
>> </services-info>
>>
>>
>> I am using jwsdp 1.5
>>
>>
>> thanks,
>> -chikkala
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>