users@jaxb.java.net

Re: Bind existing class to existing schema HOWTO

From: Sekhar Vajjhala <Sekhar.Vajjhala_at_Sun.COM>
Date: Tue, 21 Jun 2005 16:47:59 -0400

Dmitri Colebatch wrote:

>Thanks Sekhar, I'll update my page on the wiki as appropriate, a
>couple of comments though:
>
>On 6/21/05, Sekhar Vajjhala <Sekhar.Vajjhala_at_sun.com> wrote:
>
>
>>>Step two - identify the root element for the class, add the
>>>appropriate annotation to the top of the class:
>>>
>>> @XmlRootElement(name = "ElementName", namespace = "ElementNamespace")
>>>
>>>
>>>
>>A general comment that applies to all your steps below.
>>
>>Annotations elements are defaulted as far as possible to make them
>>easier to use.
>>
>>
>
>I understand that, I'm only really talking about the scenarios where
>the defaults don't suit.
>
Ok.

>
>
>
>>This is important for Java -> schema since it reduces the amount of code
>>that needs to be annotated by a devloper. So for e.g.
>>
>>@XmlRootElement Foo {...}
>>
>>
>
>I assume you mean @XmlRootElement(name="Foo", ...)
>
I used ... to indicate that class body of class Foo has been omitted. So
I did mean:

    @XmlRootElement
     public class Foo {
           ...
     }

What I was trying to point out is that if @XmlRootElement.name() is
omitted,
then it is derived from the class name.

>
>
>
>>will by default associate a gobal element "foo" in the target namespace
>>associated
>>with the package containing the class foo.
>>
>>
>
>I think I know what you're saying, for completeness you're talking
>about section D5 of the spec, correct? I'm assuming the "..." above
>is shorthand for the omitted propOrder option?
>
Section D5 of the spec deals with mapping of package XML namespace ->
package name.
But that only applies to schema->java binding not to java->schema mapping.

Again I was pointing out defaulting rules i.e.

@XmlRootElement
public class Foo {
     ...
}

will result in a global element "Foo". Since @XmlRootElement.namespace()
is not
specified it will default to "##default" which implies that the XML
namespace is
that to which the package containing the class is mapped.

>
>
>
>>For java->schema, JAXB 2.0 does really try to handle as many of the
>>existing classes as possible.
>>So non Javabeans can be handled using @XmlJavaTypeAdapter.
>>By tweak are you talking about tweaking bits and pieces, are you
>>referring to
>>tweaking application code or adding annotations to get the desired
>>XML/schema ?
>>
>>
>
>The latter. In my case (and perhaps this could be fixed by a whole
>bunch of intellij renaming) I have a bunch of classes where the
>structure maps, but the names don't.
>
Ok. Thanks

>
>thanks again,
>dim
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
>
regards,
Sekhar Vajjhala