users@jaxb.java.net

Re: Why JAXB do like this

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Wed, 29 Aug 2007 10:48:55 +0200

Hi.

> It is interesting: I have xsd with root element politikensforlag which
> looks like:
>
> <xsd:element name="politikensforlag"
> type="PolicyIdenticalPublisher" />
>
> <xsd:complexType name="PolicyIdenticalPublisher">
> <xsd:sequence minOccurs="1" maxOccurs="unbounded">
> <xsd:element name="item" type="Item"/>
> </xsd:sequence>
> </xsd:complexType>
>
> ........................
>
> Than JAXB generates me
> /**
> * Create an instance of {_at_link PolicyIdenticalPublisher }
> *
> */
> public PolicyIdenticalPublisher
> createPolicyIdenticalPublisher() {
> return new PolicyIdenticalPublisher();
> }
>
> /**
> * Create an instance of {_at_link JAXBElement }{_at_code <}{_at_link
> PolicyIdenticalPublisher }{_at_code >}}
> *
> */
> @XmlElementDecl(namespace = "", name = "politikensforlag")
> public JAXBElement<PolicyIdenticalPublisher>
> createPolitikensforlag(PolicyIdenticalPublisher value) {
> return new
> JAXBElement<PolicyIdenticalPublisher>(_Politikensforlag_QNAME,
> PolicyIdenticalPublisher.class, null, value);
> }
>
>
> Than after invoking
> u.unmarshal(xsdf_file);
> returns me JAXBElement<PolicyIdenticalPublisher>, but not
> PolicyIdenticalPublisher. Why?

If you'd have another element like

<xsd:element name="anotherPolitikensforlag" type="PolicyIdenticalPublisher" />

how would you distnitguish two PolicyIdenticalPublisher elements?

Bye.
/lexi