On Fri, Nov 19, 2010 at 1:04 PM, Dennis Sosnoski <d...@sosnoski.com> wrote:

> What makes flexible='true' combined with ordered='true' more complex is the
> need to support optional elements. At any point in the parse, the next
> element in the input may be the next element in your schema sequence, or
> *any following element up to and including the first required element*, or
> any other element (which should be ignored). Probably the best way to handle
> this in code is to use a state index for the elements in the sequence (state
> 'n' meaning we've parsed the first 'n' elements in the sequence), and again
> use a switch statement on the element name but this time combine it with
> some state logic (to assure that the known elements are in order, and that
> required ones aren't skipped). But then what do you do with the same element
> name used more than once at different points in the sequence?
>

Thanks, now it makes sense... I wasn't thinking of the impact of optional
elements.

This comment is totally blue sky but this complexity makes me wonder if it
would make more sense to implement JiBX with the assistance of a
context-free grammar parsing tool like Antlr (the Java equivalent of
bison/yacc). The terminals in your language would be XML parse events and
the input document would be the streamed XML parse. Then the JiBX compiler's
job would be to generate the grammar file (including semantic actions)
appropriate for the parse.

Anyway thanks for the explanation.

-Archie

-- 
Archie L. Cobbs
------------------------------------------------------------------------------
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