You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Ajith Ranabahu <aj...@gmail.com> on 2005/09/01 10:28:41 UTC

[Axis2] [XMLBeans] handling binary content with data binding

Hi all,
As most of you know already XML Beans is used as one of the databinding 
frameworks for Axis2. Although it was planned to add multiple framework 
support, most of the work has been done only for XMLBeans and I guess it is 
the practically usable one at the moment. However when integrating MTOM with 
databinding we have slight problems.

1. Use of the Xmime schema extension. have a look at the following piece of 
schema. (this is from http://www.w3.org/TR/xml-media-types/)

<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://example.com/know-type"
           xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
           targetNamespace="http://example.com/know-type">
    <xs:import namespace="http://www.w3.org/2005/05/xmlmime"
            schemaLocation="http://www.w3.org/2005/05/xmlmime"/>
    <xs:element name="JPEGPicture" type="xmime:base64Binary"
            xmime:expectedContentTypes="image/jpeg" />
</xs:schema>

The xmime:expectedContentTypes attribute is the key here. As you can see 
this attribute says what is the expected type of the binary content. The 
right thing to do in the above case would be to generate the databind object 
and have it return an image object as the result of data binding depending 
on the expected content type. I'm not sure how much work has been done with 
XMLBeans (or any of the other databinding frameworks for that matter) 
regarding this but if the databinding framework is unaware of this, it 
seriously limits our ability to handle MTOM with databinding!

2. Optimizing given text elements.Currently the code generated stubs can 
work with byte arrays but sending content in optimized form is the problem. 
XMLBeans is the one who sees that particular objects are base64 binary 
(which can be optimized) but this information is burnt into the XMLBeans 
generated classes and there's no way to propogate it to the OM tree (at 
least I don't see a way yet). Hence when writing to the wire, we have no way 
of saying which character items to optimize. We can do a global optimization 
(all text nodes are optimized!) but i' m not sure whether that'll work at 
all since optimization assumes the content to be bas64 encoded (in which 
case it tries to decode!)

Any thoughts on how to deal with these problems ?

BTW I've cc'ed this to the XMLBeans list as well, perhaps the XBeans gurus 
can shed some light on this issue :)

-- 
Ajith Ranabahu

Re: [Axis2] [XMLBeans] handling binary content with data binding

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
On Fri, 2005-09-02 at 00:16 -0700, Dennis Sosnoski wrote:
> The real solution is for XMLBeans to support MTOM directly, as I'm 
> planning to do with JiBX. 

Right .. almost (I think). Really what XMLBeans and JiBX and any other
data binding thing needs to support is the
http://www.w3.org/TR/xml-media-types/ spec which basically is an
extension of XML Schema to support media types. That really has nothing
to do with Web services or serialization/deserialization. (That's why
the WSDL WG which wrote that spec in trying to support MTOM in WSDL,
decided to separate that out totally.)

> As long as we use a reasonably clean interface 
> to the transport layer for getting attachments when unmarshalling and 
> setting them when marshalling we should be able to work with any data 
> binding framework that understands attachments. If JiBX turns out to be 
> the first one to support this we can work out the interface details then.

+1! At this time AFAIK only AXIOM really supports MTOM fully in its
guts: where "attachments" disappear into the tree. If you can help
figure out the interface to get that hooked up properly with a data
binder that understands the media types spec above that'll be very
valuable. Certainly worth separating that API (new JSR? Nahhh too much
politics ..).

Sanjiva.


Re: [Axis2] [XMLBeans] handling binary content with data binding

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Ajith Ranabahu wrote:

> <snip>
> With the current code generator what happens is that XMLBeans 
> generates the correct object for binary representation but always 
> serializes it into a base64 string. The input however works since 
> extracting the binary part from the mime part is done by the 
> MTOMbuilder before data binding. As it stands now, the generated stubs 
> *can* handle incoming optimized messages but never sends out an 
> optimized message!

But I think this still means that XMLBeans is reading the binary part as 
base64 and storing it that way internally, doesn't it?

The real solution is for XMLBeans to support MTOM directly, as I'm 
planning to do with JiBX. As long as we use a reasonably clean interface 
to the transport layer for getting attachments when unmarshalling and 
setting them when marshalling we should be able to work with any data 
binding framework that understands attachments. If JiBX turns out to be 
the first one to support this we can work out the interface details then.

  - Dennis

Re: [Axis2] [XMLBeans] handling binary content with data binding

Posted by Ajith Ranabahu <aj...@gmail.com>.
Hi Dennis,
You are absolutely right on the XMLBeans behavior. With the current code 
generator what happens is that XMLBeans generates the correct object for 
binary representation but always serializes it into a base64 string. The 
input however works since extracting the binary part from the mime part is 
done by the MTOMbuilder before data binding. As it stands now, the generated 
stubs *can* handle incoming optimized messages but never sends out an 
optimized message!
So I guess we should dig deep into XMLBeans (or any other framework) if we 
are to solve this!

On 9/2/05, Dennis Sosnoski <dm...@sosnoski.com> wrote:
> 
> I may be misunderstanding how XMLBeans works, but I don't see any way
> it's possible to add MTOM support without the data binding framework
> being aware of it. In the XMLBeans case I'd think that the underlying
> XML store would also need to be extended - otherwise it seems like
> XMLBeans would insist on storing the data as base64 encoding, and would
> also expect the data in that form on input and supply the data in that
> form on output.
> 
> That's one of the drawback to the layering violations built into the
> whole MTOM approach. See the earlier thread discussing this:
> http://marc.theaimsgroup.com/?t=112131750700001&r=1&w=2
> 
> - Dennis
> 
> 
> 


-- 
Ajith Ranabahu

Re: [Axis2] [XMLBeans] handling binary content with data binding

Posted by Davanum Srinivas <da...@gmail.com>.
Dennis,

this is currently a research/hack effort. let's see what info we can
extract and then we can decide what to do next. worst case, no mtom if
you use databinding...

thanks,
dims

On 9/1/05, Dennis Sosnoski <dm...@sosnoski.com> wrote:
> I may be misunderstanding how XMLBeans works, but I don't see any way
> it's possible to add MTOM support without the data binding framework
> being aware of it. In the XMLBeans case I'd think that the underlying
> XML store would also need to be extended - otherwise it seems like
> XMLBeans would insist on storing the data as base64 encoding, and would
> also expect the data in that form on input and supply the data in that
> form on output.
> 
> That's one of the drawback to the layering violations built into the
> whole MTOM approach. See the earlier thread discussing this:
> http://marc.theaimsgroup.com/?t=112131750700001&r=1&w=2
> 
>   - Dennis
> 
> Davanum Srinivas wrote:
> 
> >Ajith,
> >
> >Could you walk the schema stuff as mentioned here:
> >http://mail-archives.apache.org/mod_mbox/xmlbeans-dev/200508.mbox/%3c4B2B4C417991364996F035E1EE39E2E10294F4A3@uskiex01.amer.bea.com%3e
> >
> >"The way I would do it is: compile the schemas using the API
> >(XmlBeans.compileXmlBeans()) instead of using "scomp", get a
> >SchemaTypeSystem back and call .globalElements() and .globalTypes() on
> >it."
> >
> >If we can extract enough info from the SchemaTypeSystem, we can store
> >it somehow and use it when we have to do MTOM.
> >
> >thanks,
> >dims
> >
> >On 9/1/05, Ajith Ranabahu <aj...@gmail.com> wrote:
> >
> >
> >>Hi all,
> >> As most of you know already XML Beans is used as one of the databinding
> >>frameworks for Axis2. Although it was planned to add multiple framework
> >>support, most of the work has been done only for XMLBeans and I guess it is
> >>the practically usable one at the moment. However when integrating MTOM with
> >>databinding we have slight problems.
> >>
> >> 1. Use of the Xmime schema extension. have a look at the following piece of
> >>schema. (this is from
> >>http://www.w3.org/TR/xml-media-types/)
> >> <?xml version="1.0" ?>
> >><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> >> xmlns:tns="
> >>http://example.com/know-type"
> >> xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
> >> targetNamespace="
> >>http://example.com/know-type">
> >> <xs:import namespace="http://www.w3.org/2005/05/xmlmime"
> >> schemaLocation="
> >>http://www.w3.org/2005/05/xmlmime"/>
> >> <xs:element name="JPEGPicture" type="xmime:base64Binary"
> >> xmime:expectedContentTypes="image/jpeg" />
> >></xs:schema>
> >>
> >> The xmime:expectedContentTypes attribute is the key here. As you can see
> >>this attribute says what is the expected type of the binary content. The
> >>right thing to do in the above case would be to generate the databind object
> >>and have it return an image object as the result of data binding depending
> >>on the expected content type. I'm not sure how much work has been done with
> >>XMLBeans (or any of the other databinding frameworks for that matter)
> >>regarding this but if the databinding framework is unaware of this, it
> >>seriously limits our ability to handle MTOM with databinding!
> >>
> >> 2. Optimizing given text elements.Currently the code generated stubs can
> >>work with byte arrays but sending content in optimized form is the problem.
> >>XMLBeans is the one who sees that particular objects are base64 binary
> >>(which can be optimized) but this information is burnt into the XMLBeans
> >>generated classes and there's no way to propogate it to the OM tree (at
> >>least I don't see a way yet). Hence when writing to the wire, we have no way
> >>of saying which character items to optimize. We can do a global optimization
> >>(all text nodes are optimized!) but i' m not sure whether that'll work at
> >>all since optimization assumes the content to be bas64 encoded (in which
> >>case it tries to decode!)
> >>
> >> Any thoughts on how to deal with these problems ?
> >>
> >> BTW I've cc'ed this to the XMLBeans list as well, perhaps the XBeans gurus
> >>can shed some light on this issue :)
> >>
> >>--
> >>Ajith Ranabahu
> >>
> >>
> >
> >
> >
> >
> 


-- 
Davanum Srinivas : http://wso2.com/ - Oxygenating The Web Service Platform

Re: [Axis2] [XMLBeans] handling binary content with data binding

Posted by Davanum Srinivas <da...@gmail.com>.
Dennis,

this is currently a research/hack effort. let's see what info we can
extract and then we can decide what to do next. worst case, no mtom if
you use databinding...

thanks,
dims

On 9/1/05, Dennis Sosnoski <dm...@sosnoski.com> wrote:
> I may be misunderstanding how XMLBeans works, but I don't see any way
> it's possible to add MTOM support without the data binding framework
> being aware of it. In the XMLBeans case I'd think that the underlying
> XML store would also need to be extended - otherwise it seems like
> XMLBeans would insist on storing the data as base64 encoding, and would
> also expect the data in that form on input and supply the data in that
> form on output.
> 
> That's one of the drawback to the layering violations built into the
> whole MTOM approach. See the earlier thread discussing this:
> http://marc.theaimsgroup.com/?t=112131750700001&r=1&w=2
> 
>   - Dennis
> 
> Davanum Srinivas wrote:
> 
> >Ajith,
> >
> >Could you walk the schema stuff as mentioned here:
> >http://mail-archives.apache.org/mod_mbox/xmlbeans-dev/200508.mbox/%3c4B2B4C417991364996F035E1EE39E2E10294F4A3@uskiex01.amer.bea.com%3e
> >
> >"The way I would do it is: compile the schemas using the API
> >(XmlBeans.compileXmlBeans()) instead of using "scomp", get a
> >SchemaTypeSystem back and call .globalElements() and .globalTypes() on
> >it."
> >
> >If we can extract enough info from the SchemaTypeSystem, we can store
> >it somehow and use it when we have to do MTOM.
> >
> >thanks,
> >dims
> >
> >On 9/1/05, Ajith Ranabahu <aj...@gmail.com> wrote:
> >
> >
> >>Hi all,
> >> As most of you know already XML Beans is used as one of the databinding
> >>frameworks for Axis2. Although it was planned to add multiple framework
> >>support, most of the work has been done only for XMLBeans and I guess it is
> >>the practically usable one at the moment. However when integrating MTOM with
> >>databinding we have slight problems.
> >>
> >> 1. Use of the Xmime schema extension. have a look at the following piece of
> >>schema. (this is from
> >>http://www.w3.org/TR/xml-media-types/)
> >> <?xml version="1.0" ?>
> >><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> >> xmlns:tns="
> >>http://example.com/know-type"
> >> xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
> >> targetNamespace="
> >>http://example.com/know-type">
> >> <xs:import namespace="http://www.w3.org/2005/05/xmlmime"
> >> schemaLocation="
> >>http://www.w3.org/2005/05/xmlmime"/>
> >> <xs:element name="JPEGPicture" type="xmime:base64Binary"
> >> xmime:expectedContentTypes="image/jpeg" />
> >></xs:schema>
> >>
> >> The xmime:expectedContentTypes attribute is the key here. As you can see
> >>this attribute says what is the expected type of the binary content. The
> >>right thing to do in the above case would be to generate the databind object
> >>and have it return an image object as the result of data binding depending
> >>on the expected content type. I'm not sure how much work has been done with
> >>XMLBeans (or any of the other databinding frameworks for that matter)
> >>regarding this but if the databinding framework is unaware of this, it
> >>seriously limits our ability to handle MTOM with databinding!
> >>
> >> 2. Optimizing given text elements.Currently the code generated stubs can
> >>work with byte arrays but sending content in optimized form is the problem.
> >>XMLBeans is the one who sees that particular objects are base64 binary
> >>(which can be optimized) but this information is burnt into the XMLBeans
> >>generated classes and there's no way to propogate it to the OM tree (at
> >>least I don't see a way yet). Hence when writing to the wire, we have no way
> >>of saying which character items to optimize. We can do a global optimization
> >>(all text nodes are optimized!) but i' m not sure whether that'll work at
> >>all since optimization assumes the content to be bas64 encoded (in which
> >>case it tries to decode!)
> >>
> >> Any thoughts on how to deal with these problems ?
> >>
> >> BTW I've cc'ed this to the XMLBeans list as well, perhaps the XBeans gurus
> >>can shed some light on this issue :)
> >>
> >>--
> >>Ajith Ranabahu
> >>
> >>
> >
> >
> >
> >
> 


-- 
Davanum Srinivas : http://wso2.com/ - Oxygenating The Web Service Platform

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


Re: [Axis2] [XMLBeans] handling binary content with data binding

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
I may be misunderstanding how XMLBeans works, but I don't see any way 
it's possible to add MTOM support without the data binding framework 
being aware of it. In the XMLBeans case I'd think that the underlying 
XML store would also need to be extended - otherwise it seems like 
XMLBeans would insist on storing the data as base64 encoding, and would 
also expect the data in that form on input and supply the data in that 
form on output.

That's one of the drawback to the layering violations built into the 
whole MTOM approach. See the earlier thread discussing this: 
http://marc.theaimsgroup.com/?t=112131750700001&r=1&w=2

  - Dennis

Davanum Srinivas wrote:

>Ajith,
>
>Could you walk the schema stuff as mentioned here:
>http://mail-archives.apache.org/mod_mbox/xmlbeans-dev/200508.mbox/%3c4B2B4C417991364996F035E1EE39E2E10294F4A3@uskiex01.amer.bea.com%3e
>
>"The way I would do it is: compile the schemas using the API
>(XmlBeans.compileXmlBeans()) instead of using "scomp", get a
>SchemaTypeSystem back and call .globalElements() and .globalTypes() on
>it."
>
>If we can extract enough info from the SchemaTypeSystem, we can store
>it somehow and use it when we have to do MTOM.
>
>thanks,
>dims
>
>On 9/1/05, Ajith Ranabahu <aj...@gmail.com> wrote:
>  
>
>>Hi all,
>> As most of you know already XML Beans is used as one of the databinding
>>frameworks for Axis2. Although it was planned to add multiple framework
>>support, most of the work has been done only for XMLBeans and I guess it is
>>the practically usable one at the moment. However when integrating MTOM with
>>databinding we have slight problems.
>> 
>> 1. Use of the Xmime schema extension. have a look at the following piece of
>>schema. (this is from
>>http://www.w3.org/TR/xml-media-types/)
>> <?xml version="1.0" ?>
>><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> xmlns:tns="
>>http://example.com/know-type"
>> xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
>> targetNamespace="
>>http://example.com/know-type">
>> <xs:import namespace="http://www.w3.org/2005/05/xmlmime"
>> schemaLocation="
>>http://www.w3.org/2005/05/xmlmime"/>
>> <xs:element name="JPEGPicture" type="xmime:base64Binary"
>> xmime:expectedContentTypes="image/jpeg" />
>></xs:schema>
>>
>> The xmime:expectedContentTypes attribute is the key here. As you can see
>>this attribute says what is the expected type of the binary content. The
>>right thing to do in the above case would be to generate the databind object
>>and have it return an image object as the result of data binding depending
>>on the expected content type. I'm not sure how much work has been done with
>>XMLBeans (or any of the other databinding frameworks for that matter)
>>regarding this but if the databinding framework is unaware of this, it
>>seriously limits our ability to handle MTOM with databinding!
>> 
>> 2. Optimizing given text elements.Currently the code generated stubs can
>>work with byte arrays but sending content in optimized form is the problem.
>>XMLBeans is the one who sees that particular objects are base64 binary
>>(which can be optimized) but this information is burnt into the XMLBeans
>>generated classes and there's no way to propogate it to the OM tree (at
>>least I don't see a way yet). Hence when writing to the wire, we have no way
>>of saying which character items to optimize. We can do a global optimization
>>(all text nodes are optimized!) but i' m not sure whether that'll work at
>>all since optimization assumes the content to be bas64 encoded (in which
>>case it tries to decode!)
>> 
>> Any thoughts on how to deal with these problems ?
>> 
>> BTW I've cc'ed this to the XMLBeans list as well, perhaps the XBeans gurus
>>can shed some light on this issue :)
>>
>>-- 
>>Ajith Ranabahu 
>>    
>>
>
>
>  
>

Re: [Axis2] [XMLBeans] handling binary content with data binding

Posted by Davanum Srinivas <da...@gmail.com>.
Ajith,

we can't override what they generate, i just want us to note which
elements are marked by the xmime stuff and do the needful at runtime
(extract the contents that are base64'ed and then MTOM-it)

-- dims

On 9/1/05, Ajith Ranabahu <aj...@gmail.com> wrote:
> Hi Dims,
>  This is exactly the approach that I have taken. I never call 'scomp' :) .
> Instead the schema DOM element is fed into the XMLBeans.CompileXMLBeans()
> method to generate a schema type system and then from that I take the
> Document types (schemas) and a make a mapping.
>  Have a look at the XMLBeansExtension class and you'll see how Axis2
> interacts with XMLBeans.
>  
>  But I don't think this approach will solve our problem. I mean the real
> problem seems to be that XMLBeans does not realize the semantics of the
> xmime extension. We may be able to extract which elements are base64 (I have
> to check that !) but still the root problem remains. We should get our feet
> wet and dig into XMLBeans to solve it :) (Unless the XMLbeans guys have
> already done something to make it easy for us :)))
> 
> On 9/2/05, Davanum Srinivas <da...@gmail.com> wrote: 
> > Ajith,
> > 
> > Could you walk the schema stuff as mentioned here:
> >
> http://mail-archives.apache.org/mod_mbox/xmlbeans-dev/200508.mbox/%3c4B2B4C417991364996F035E1EE39E2E10294F4A3@uskiex01.amer.bea.com%3e
> > 
> > "The way I would do it is: compile the schemas using the API
> > (XmlBeans.compileXmlBeans ()) instead of using "scomp", get a
> > SchemaTypeSystem back and call .globalElements() and .globalTypes() on
> > it."
> > 
> > If we can extract enough info from the SchemaTypeSystem, we can store
> > it somehow and use it when we have to do MTOM. 
> > 
> > thanks,
> > dims
> > 
> > 
> > 
> 
> 
> 
> -- 
> Ajith Ranabahu 


-- 
Davanum Srinivas : http://wso2.com/ - Oxygenating The Web Service Platform

Re: [Axis2] [XMLBeans] handling binary content with data binding

Posted by Davanum Srinivas <da...@gmail.com>.
Ajith,

we can't override what they generate, i just want us to note which
elements are marked by the xmime stuff and do the needful at runtime
(extract the contents that are base64'ed and then MTOM-it)

-- dims

On 9/1/05, Ajith Ranabahu <aj...@gmail.com> wrote:
> Hi Dims,
>  This is exactly the approach that I have taken. I never call 'scomp' :) .
> Instead the schema DOM element is fed into the XMLBeans.CompileXMLBeans()
> method to generate a schema type system and then from that I take the
> Document types (schemas) and a make a mapping.
>  Have a look at the XMLBeansExtension class and you'll see how Axis2
> interacts with XMLBeans.
>  
>  But I don't think this approach will solve our problem. I mean the real
> problem seems to be that XMLBeans does not realize the semantics of the
> xmime extension. We may be able to extract which elements are base64 (I have
> to check that !) but still the root problem remains. We should get our feet
> wet and dig into XMLBeans to solve it :) (Unless the XMLbeans guys have
> already done something to make it easy for us :)))
> 
> On 9/2/05, Davanum Srinivas <da...@gmail.com> wrote: 
> > Ajith,
> > 
> > Could you walk the schema stuff as mentioned here:
> >
> http://mail-archives.apache.org/mod_mbox/xmlbeans-dev/200508.mbox/%3c4B2B4C417991364996F035E1EE39E2E10294F4A3@uskiex01.amer.bea.com%3e
> > 
> > "The way I would do it is: compile the schemas using the API
> > (XmlBeans.compileXmlBeans ()) instead of using "scomp", get a
> > SchemaTypeSystem back and call .globalElements() and .globalTypes() on
> > it."
> > 
> > If we can extract enough info from the SchemaTypeSystem, we can store
> > it somehow and use it when we have to do MTOM. 
> > 
> > thanks,
> > dims
> > 
> > 
> > 
> 
> 
> 
> -- 
> Ajith Ranabahu 


-- 
Davanum Srinivas : http://wso2.com/ - Oxygenating The Web Service Platform

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


Re: [Axis2] [XMLBeans] handling binary content with data binding

Posted by Ajith Ranabahu <aj...@gmail.com>.
Hi Dims,
This is exactly the approach that I have taken. I never call 'scomp' :) . 
Instead the schema DOM element is fed into the XMLBeans.CompileXMLBeans() 
method to generate a schema type system and then from that I take the 
Document types (schemas) and a make a mapping.
Have a look at the XMLBeansExtension class and you'll see how Axis2 
interacts with XMLBeans.

But I don't think this approach will solve our problem. I mean the real 
problem seems to be that XMLBeans does not realize the semantics of the 
xmime extension. We may be able to extract which elements are base64 (I have 
to check that !) but still the root problem remains. We should get our feet 
wet and dig into XMLBeans to solve it :) (Unless the XMLbeans guys have 
already done something to make it easy for us :)))

On 9/2/05, Davanum Srinivas <da...@gmail.com> wrote:
> 
> Ajith,
> 
> Could you walk the schema stuff as mentioned here:
> 
> http://mail-archives.apache.org/mod_mbox/xmlbeans-dev/200508.mbox/%3c4B2B4C417991364996F035E1EE39E2E10294F4A3@uskiex01.amer.bea.com%3e
> 
> "The way I would do it is: compile the schemas using the API
> (XmlBeans.compileXmlBeans()) instead of using "scomp", get a
> SchemaTypeSystem back and call .globalElements() and .globalTypes() on
> it."
> 
> If we can extract enough info from the SchemaTypeSystem, we can store
> it somehow and use it when we have to do MTOM.
> 
> thanks,
> dims
> 
> 
> 


-- 
Ajith Ranabahu

Re: [Axis2] [XMLBeans] handling binary content with data binding

Posted by Ajith Ranabahu <aj...@gmail.com>.
Hi Dims,
This is exactly the approach that I have taken. I never call 'scomp' :) . 
Instead the schema DOM element is fed into the XMLBeans.CompileXMLBeans() 
method to generate a schema type system and then from that I take the 
Document types (schemas) and a make a mapping.
Have a look at the XMLBeansExtension class and you'll see how Axis2 
interacts with XMLBeans.

But I don't think this approach will solve our problem. I mean the real 
problem seems to be that XMLBeans does not realize the semantics of the 
xmime extension. We may be able to extract which elements are base64 (I have 
to check that !) but still the root problem remains. We should get our feet 
wet and dig into XMLBeans to solve it :) (Unless the XMLbeans guys have 
already done something to make it easy for us :)))

On 9/2/05, Davanum Srinivas <da...@gmail.com> wrote:
> 
> Ajith,
> 
> Could you walk the schema stuff as mentioned here:
> 
> http://mail-archives.apache.org/mod_mbox/xmlbeans-dev/200508.mbox/%3c4B2B4C417991364996F035E1EE39E2E10294F4A3@uskiex01.amer.bea.com%3e
> 
> "The way I would do it is: compile the schemas using the API
> (XmlBeans.compileXmlBeans()) instead of using "scomp", get a
> SchemaTypeSystem back and call .globalElements() and .globalTypes() on
> it."
> 
> If we can extract enough info from the SchemaTypeSystem, we can store
> it somehow and use it when we have to do MTOM.
> 
> thanks,
> dims
> 
> 
> 


-- 
Ajith Ranabahu

Re: [Axis2] [XMLBeans] handling binary content with data binding

Posted by Davanum Srinivas <da...@gmail.com>.
Ajith,

Could you walk the schema stuff as mentioned here:
http://mail-archives.apache.org/mod_mbox/xmlbeans-dev/200508.mbox/%3c4B2B4C417991364996F035E1EE39E2E10294F4A3@uskiex01.amer.bea.com%3e

"The way I would do it is: compile the schemas using the API
(XmlBeans.compileXmlBeans()) instead of using "scomp", get a
SchemaTypeSystem back and call .globalElements() and .globalTypes() on
it."

If we can extract enough info from the SchemaTypeSystem, we can store
it somehow and use it when we have to do MTOM.

thanks,
dims

On 9/1/05, Ajith Ranabahu <aj...@gmail.com> wrote:
> Hi all,
>  As most of you know already XML Beans is used as one of the databinding
> frameworks for Axis2. Although it was planned to add multiple framework
> support, most of the work has been done only for XMLBeans and I guess it is
> the practically usable one at the moment. However when integrating MTOM with
> databinding we have slight problems.
>  
>  1. Use of the Xmime schema extension. have a look at the following piece of
> schema. (this is from
> http://www.w3.org/TR/xml-media-types/)
>  <?xml version="1.0" ?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>  xmlns:tns="
> http://example.com/know-type"
>  xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
>  targetNamespace="
> http://example.com/know-type">
>  <xs:import namespace="http://www.w3.org/2005/05/xmlmime"
>  schemaLocation="
> http://www.w3.org/2005/05/xmlmime"/>
>  <xs:element name="JPEGPicture" type="xmime:base64Binary"
>  xmime:expectedContentTypes="image/jpeg" />
> </xs:schema>
> 
>  The xmime:expectedContentTypes attribute is the key here. As you can see
> this attribute says what is the expected type of the binary content. The
> right thing to do in the above case would be to generate the databind object
> and have it return an image object as the result of data binding depending
> on the expected content type. I'm not sure how much work has been done with
> XMLBeans (or any of the other databinding frameworks for that matter)
> regarding this but if the databinding framework is unaware of this, it
> seriously limits our ability to handle MTOM with databinding!
>  
>  2. Optimizing given text elements.Currently the code generated stubs can
> work with byte arrays but sending content in optimized form is the problem.
> XMLBeans is the one who sees that particular objects are base64 binary
> (which can be optimized) but this information is burnt into the XMLBeans
> generated classes and there's no way to propogate it to the OM tree (at
> least I don't see a way yet). Hence when writing to the wire, we have no way
> of saying which character items to optimize. We can do a global optimization
> (all text nodes are optimized!) but i' m not sure whether that'll work at
> all since optimization assumes the content to be bas64 encoded (in which
> case it tries to decode!)
>  
>  Any thoughts on how to deal with these problems ?
>  
>  BTW I've cc'ed this to the XMLBeans list as well, perhaps the XBeans gurus
> can shed some light on this issue :)
> 
> -- 
> Ajith Ranabahu 


-- 
Davanum Srinivas : http://wso2.com/ - Oxygenating The Web Service Platform

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


Re: [Axis2] [XMLBeans] handling binary content with data binding

Posted by Davanum Srinivas <da...@gmail.com>.
Ajith,

Could you walk the schema stuff as mentioned here:
http://mail-archives.apache.org/mod_mbox/xmlbeans-dev/200508.mbox/%3c4B2B4C417991364996F035E1EE39E2E10294F4A3@uskiex01.amer.bea.com%3e

"The way I would do it is: compile the schemas using the API
(XmlBeans.compileXmlBeans()) instead of using "scomp", get a
SchemaTypeSystem back and call .globalElements() and .globalTypes() on
it."

If we can extract enough info from the SchemaTypeSystem, we can store
it somehow and use it when we have to do MTOM.

thanks,
dims

On 9/1/05, Ajith Ranabahu <aj...@gmail.com> wrote:
> Hi all,
>  As most of you know already XML Beans is used as one of the databinding
> frameworks for Axis2. Although it was planned to add multiple framework
> support, most of the work has been done only for XMLBeans and I guess it is
> the practically usable one at the moment. However when integrating MTOM with
> databinding we have slight problems.
>  
>  1. Use of the Xmime schema extension. have a look at the following piece of
> schema. (this is from
> http://www.w3.org/TR/xml-media-types/)
>  <?xml version="1.0" ?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>  xmlns:tns="
> http://example.com/know-type"
>  xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
>  targetNamespace="
> http://example.com/know-type">
>  <xs:import namespace="http://www.w3.org/2005/05/xmlmime"
>  schemaLocation="
> http://www.w3.org/2005/05/xmlmime"/>
>  <xs:element name="JPEGPicture" type="xmime:base64Binary"
>  xmime:expectedContentTypes="image/jpeg" />
> </xs:schema>
> 
>  The xmime:expectedContentTypes attribute is the key here. As you can see
> this attribute says what is the expected type of the binary content. The
> right thing to do in the above case would be to generate the databind object
> and have it return an image object as the result of data binding depending
> on the expected content type. I'm not sure how much work has been done with
> XMLBeans (or any of the other databinding frameworks for that matter)
> regarding this but if the databinding framework is unaware of this, it
> seriously limits our ability to handle MTOM with databinding!
>  
>  2. Optimizing given text elements.Currently the code generated stubs can
> work with byte arrays but sending content in optimized form is the problem.
> XMLBeans is the one who sees that particular objects are base64 binary
> (which can be optimized) but this information is burnt into the XMLBeans
> generated classes and there's no way to propogate it to the OM tree (at
> least I don't see a way yet). Hence when writing to the wire, we have no way
> of saying which character items to optimize. We can do a global optimization
> (all text nodes are optimized!) but i' m not sure whether that'll work at
> all since optimization assumes the content to be bas64 encoded (in which
> case it tries to decode!)
>  
>  Any thoughts on how to deal with these problems ?
>  
>  BTW I've cc'ed this to the XMLBeans list as well, perhaps the XBeans gurus
> can shed some light on this issue :)
> 
> -- 
> Ajith Ranabahu 


-- 
Davanum Srinivas : http://wso2.com/ - Oxygenating The Web Service Platform