The issue with "flexible" unmarshalling is that JiBX normally generates
code based on the expected order of elements in order to get the most
efficient processing - at any point in the unmarshalling it can just
check for the next expected element, and if it's not found skip to the
following one, an approach that works very well with a pull parser.
So-called "flexible" unmarshalling instead requires that it look at the
element name and then fan-out for processing based on that name.

For 2.0 I'm planning better handling of this case, but it's always going
to be somewhat ugly.

Incidentally, http://jira.codehaus.org/browse/JIBX-397 appears to be
mis-titled - it looks like it should be "Allow setting flexible='true'
and ordered='true' at the same time. I'm looking into an easy
work-around for this case now, based on using a DOM mapper that handles
anything other than the specified namespace.

  - Dennis

Dennis M. Sosnoski
Java SOA and Web Services Consulting <http://www.sosnoski.com/consult.html>
Axis2/CXF/Metro SOA and Web Services Training
<http://www.sosnoski.com/training.html>
Web Services Jump-Start <http://www.sosnoski.com/jumpstart.html>


On 10/20/2010 05:27 AM, Archie Cobbs wrote:
> Ironically, things get very inflexible when you specify
> flexible="true". Here are some other issues I've found:
>
> JIBX-402 <http://jira.codehaus.org/browse/JIBX-402>: JiBX fails when
> abstract type is used with flexible="true"
> JIBX-397 <http://jira.codehaus.org/browse/JIBX-397>: Allow setting
> flexible="true" and ordered="false" at the same time
>
> I don't really understand why though. It seems like there should be a
> flag in the code somewhere that says whether to reject or ignore
> unknown tags, and why simply changing that flag causes all these other
> problems.
>
> -Archie
>
> On Tue, Oct 19, 2010 at 7:53 AM, Bob Smith <ob_tr...@yahoo.fr
> <mailto:ob_tr...@yahoo.fr>> wrote:
>
>     Hello,
>
>     I have been using JiBX for a couple months on basic XML files and
>     I am really pleased especially by the performance.
>
>     I am now trying to bind an RSS format.
>     My issue is that, in RSS, the list of items is not embedded in an
>     <items> tag.
>     Example:
>     <rss>
>      <channel>
>        <item />
>        <item />
>        <item />
>      </channel>
>     </rss>
>
>     My binding is as follows:
>     <?xml version="1.0" encoding="UTF-8"?>
>     <binding name="binding" package="my.jibx.rss">
>      <mapping name="rss" class="my.jibx.rss.Feed">
>        <structure name="channel" field="channel" map-as="channel" />
>      </mapping>
>      <mapping abstract="true" type-name="channel"
>     class="my.jibx.rss.Channel" ordered="false" flexible="true">
>        <value style="element" name="link" field="link" usage="optional" />
>        <value style="element" name="title" field="title"
>     usage="optional" />
>        <value style="element" name="description" field="description"
>     usage="optional" />
>        <collection field="items" create-type="java.util.ArrayList"
>     ordered="false" />
>      </mapping>
>      <mapping name="item" class="my.jibx.rss.Item" ordered="false"
>     flexible="true">
>        <value style="element" name="title" field="title"
>     usage="optional" />
>        <value style="element" name="description" field="description"
>     usage="optional" />
>        <structure name="image" field="image" type="my.jibx.rss.Image"
>     usage="optional" ordered="false">
>          <value style="element" name="url" field="url" />
>        </structure>
>        <structure name="enclosure" field="enclosure"
>     type="my.jibx.rss.Enclosure" usage="optional" ordered="false">
>          <value style="attribute" name="url" field="url" />
>          <value style="attribute" name="type" field="type"
>     usage="optional" />
>          <value style="attribute" name="length" field="length"
>     usage="optional" />
>        </structure>
>      </mapping>
>     </binding>
>
>
>     Since I do not want to handle some elements that are unnecessary
>     to me and that others apps may add with their own namespace, I try
>     to use flexible="true" on the Channel mapping.
>     However, I cannot use flexible="true" on the Channel mapping
>     because the collection of items has no name. Error:
>
>     Error: All child components must define element names for
>     flexible='true'; on collection element at (line 10, col 83, in
>     rss-binding.xml)
>
>
>     And I cannot use a name since there is no eclosing tag in RSS.
>     How can this type of collection be handled using JiBX?
>
>     Thank you for your help.
>     Bob
>
>
>
>
>
>     
> ------------------------------------------------------------------------------
>     Download new Adobe(R) Flash(R) Builder(TM) 4
>     The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
>     Flex(R) Builder(TM)) enable the development of rich applications
>     that run
>     across multiple browsers and platforms. Download your free trials
>     today!
>     http://p.sf.net/sfu/adobe-dev2dev
>     _______________________________________________
>     jibx-users mailing list
>     jibx-users@lists.sourceforge.net
>     <mailto:jibx-users@lists.sourceforge.net>
>     https://lists.sourceforge.net/lists/listinfo/jibx-users
>
>
>
>
> -- 
> Archie L. Cobbs
>
>
> ------------------------------------------------------------------------------
> Download new Adobe(R) Flash(R) Builder(TM) 4
> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
> Flex(R) Builder(TM)) enable the development of rich applications that run
> across multiple browsers and platforms. Download your free trials today!
> http://p.sf.net/sfu/adobe-dev2dev
>
>
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>   
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to