I will elaborate some more on the matter.
The reason I (think I) need this (see below) is in the case of Value Objects
in J2EE.
We have some components that expose a data in a DB to the web tier by means
of XML schema.
In J2EE, to avoid multiple fine grained calls to retrieve data from the
business tier, you usually use Value Objects (also known as data transfer
objects) to pass objects that encapsulate bulk data. This will save you many
remote calls between tiers and now you can get a chunk of data in one call.
Because we expose that data through means of XML yet implements our business
logic in pure object form (entity beans, session beans, Value Objects), we
would like these VOs to be transferred into XML according to XML schema.
I figured that I can compile a large schema to an object that represents the
chunk of data I want to transfer and when marshaling it , the result would
be according to the large schema.
Before I got into JAXB I though I will be able to transform non precompiled
objects according to a schema at runtime. After realizing this is not the
case I figured I will achieve my goal with the custom bindings but this is
not an option also. I guess I will stick to my ugly 0 performance code that
does this at runtime (I wanted to get rid of it so well).
I would be happy to hear any comment on the specific case. By the way, some
J2EE books pointed to JAXB as a solution to what I present (apparently the
authors did not read the spec) so I was sad to see I will not be able to
achieve it.
Again, I would appreciate any suggestions in this matter. Or any other
possibility to use JAXB in this matter.
Thanks.
-----Original Message-----
From: Ryan Shoemaker - JavaSoft East [mailto:Ryan.Shoemaker_at_Sun.COM]
Sent: Wednesday, February 26, 2003 8:52 PM
To: JAXB-INTEREST_at_JAVA.SUN.COM
Subject: Re: Using Custom bindings to generate small classes for big schemas
Katz Guy wrote:
>
> Hi;
>
> Reading the jaxb user guide I couldn’t understand if I can acheve the
> following. I would appreciate any help.
>
> basically , In my project i have huge huge xml schemas and would like to
> generate a small class(or a number of small classes) per schema which
> represent a fragment of that schema.
>
> For example; We would like the schema:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
> <xs:element name="a">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="b" type="xs:string"/>
> <xs:element name="c" type="xs:string"/>
> <xs:element name="d" type="xs:string"/>
> <xs:element name="e">
> <xs:complexType>
> <xs:sequence>
> <xs:element
> name="f" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
>
> To be generated into:
> Interface <someIfc>{
> public string getB();
> public void setB(String b);
> }
> and
> Class <someName> implements <someIfc>{
> String b;
> public string getB(){return b;}
> public void setB(String b){this.b=b;}
> }
>
> Discurding most of the schema content in the generated classes. Yet when
> transforming an instance of that class into XML we would like it to
> transfrom according to the full scema.
>
> For example:
> An instance of class <someName> with string value of b set to "b" will
> be transformed into:
> <a>
> <b>b</b>
> <c/>
> <d/>
> <e>
> <f/>
> </e>
> </a>
>
> Or something like that.
>
> I figured this would be done by custom bindings but could not find the
> way to do this in the user guide.(maybe I didn’t understand the guide
> very well)
>
Guy,
The binding customizations allow you change the default bindings generated
by the compiler, but there is no way to limit the generated interfaces to
specific fragments of the schema as you described. There may be some
extremely limited use cases where you might be able to force JAXB to behave
this way, but in general this is not possible. I'll think about it some
more,
but in the mean-time, I'd be interested to know if anyone else on the list
has any thoughts...
--Ryan
> Is JAXB an apprepriate technology for this? I could not get this from
> the manual.
> I would really appreciate any respose
> Thanks.
>
>
>
> _______________________
> Guy Katz
> Comverse
> guy.katz_at_comverse.com
> +972 3 7663686
>
>