users@jaxb.java.net

Re: Having Namespace for every attribute

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Mon, 7 Dec 2009 15:47:43 +0100

Why would you want to have the NS prefixes in all sub-elements? The
resulting
XML is perfectly valid since omitting NS prefixes means that the parent
element's
namespace is inherited.

-W

On Wed, Dec 2, 2009 at 7:02 PM, Chandran R <ramu.chandran_at_gmail.com> wrote:

>
> Hi All,
>
> We would like to use annotations and take advantage of jaxb for marshalling
> ang unmarshalling the Java Objects.
> These Objects are legacy code and hence we would like to add annotations
> only at class level i.e @XmlRootElement(name = "Title" ,
> namespace="com.company.referencedata")
>
> For ex
>
> @XmlRootElement(name = "Title" , namespace="com.company.referencedata")
> public class Title {
> private int id;
> ...
> }
>
> What we have observed was the xml generated on marshalling had namespace
> included only for rootNode
>
> ex:
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <ns2:Title xmlns:ns2="com.company.referencedata">
> <description>description</description>
> <id>1</id>
> </ns2:Title>
>
> We expected it to add even for elements
>
> ex :
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <ns2:Title xmlns:ns2="com.company.referencedata">
> <ns2:description>description</ns2:description>
> <ns2:id>1</ns2:id>
> </ns2:Title>
>
>
> One solution is add @XMLElement for all the attributes, but is there any
> other way where we could include namespace ??
>
> I am new to JAXB, Any help is highly appreciated.
>
> Thanks In Advance
>
>
>
>
>
> --
> View this message in context:
> http://old.nabble.com/Having-Namespace-for-every-attribute-tp26613484p26613484.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>