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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to