Hmmmmm,
In J2EE 5 Tutorial I saw this code
JAXBContext jc = JAXBContext.newInstance( "primer.po" );
Unmarshaller u = jc.createUnmarshaller();
PurchaseOrder po =
(PurchaseOrder)u.unmarshal(
new FileInputStream( "po.xml" ) );
In po.xsd
<xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
And my structure the same. And in xsd I define only one element with
PolicyIdenticalPublisher type
"
and it works properly without JAXBElement
On 8/29/07, Aleksei Valikov <valikov_at_gmx.net> wrote:
>
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
--
Denis Bessmertnyj
+3 8 050 1030623
ICQ: 7780453