Re: [xml] xmllint reports non-determinist content model for schema

2012-08-23 Thread Daniel Veillard
On Wed, Aug 22, 2012 at 10:40:20PM +0200, Johan Corveleyn wrote:
 On Fri, Aug 17, 2012 at 10:32 PM, Johan Corveleyn jcor...@gmail.com wrote:
  On Fri, Feb 24, 2012 at 2:14 PM, Johan Corveleyn jcor...@gmail.com wrote:
  ...
  I'm running into a non-determinist error with a schema even though I
  don't think it's non-determinist (and both XSV and Xerces agree with
  me; they too have no problem with the schema). I have reduced my
  test-case to a simple example, see below.
 
  On Tue, Feb 28, 2012 at 6:00 AM, Daniel Veillard veill...@redhat.com 
  wrote:
  ...
   Well in that case it seems the underlying code is generating a
  wrong automata so it should be a matter of running that minimal
  test case under gdb with the breakpoint appropriately set to find out
  what wrong transition got added ...
 
  I'd like to take a stab at this issue. I've been able to get the
  latest 2.9.0 snapshot (from
  ftp://xmlsoft.org/libxml2/libxml2-git-snapshot.tar.gz) to build in
  Visual Studio 2010. I can still reproduce the issue.
 
  But I need some guidance. What part of the code should I be looking
  at? Where do I have to set the breakpoint appropriately to find out
  the wrong transition that got added?
 
  Alternatively, if you or anyone else on this list can fix the issue
  already, that would be even better :-).
 
  To summarize, the issue is this:
  Given the following schema:
 
  ?xml version=1.0 encoding=UTF-8?
  xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema;
  xs:element name=rules
  xs:complexType
  xs:sequence
  xs:element name=rule 
  minOccurs=0 maxOccurs=unbounded/
  xs:sequence minOccurs=0 
  maxOccurs=1
  xs:element 
  name=specialRule minOccurs=1 maxOccurs=1/
  xs:element name=rule 
  minOccurs=0 maxOccurs=unbounded/
  /xs:sequence
  /xs:sequence
  /xs:complexType
  /xs:element
  /xs:schema
 
  xmllint complains with Schemas parser error : local
  complex type: The content model is not determinist.
  But it isn't.
 
  See also https://bugzilla.gnome.org/show_bug.cgi?id=670865.
 
 Hi,
 
 I could really use some guidance here. I've been able to set up
 everything in Visual Studio 2010, and reproduced the issue from within
 the debugger. So I can set a breakpoint etc. But I mostly lack some
 basic knowledge about how this all works.
 
 Is there some (preferable concise) reading about basic concepts like
 how xml schemas automata work, how these are built, etc? What should
 the automata in this case look like (in terms of the data structures
 inside the code)? How can I see that the automata is non-determinist,
 and what would a determinist automata look like, ... ?

Johan,

  sorry for the slow answer,

I will look at this, promise, but all that code is rooted in automata
theory, there is quite some litterature about it, and well unless you
go though the process of learning that code and possibly the theory
behind it, it's not something that can be hacked trivially. Basically
I run this in debug mode, look at the automata generated, there is pro
bably an error there and then this need fixing and a lot of checking.
To be honnest that one of the hardest part of the library to change
with the core of the parser.
  Theory is usually learnt though the 'Dragon Book', by Aho and Al.
and the code is actually more complex since using extended automata
operations not found in basic automata ...

If you have time looking at this may be interesting, but
it's really not trivial at least more complex than other parts of the
code :-)

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmllint reports non-determinist content model for schema

2012-08-23 Thread Johan Corveleyn
On Thu, Aug 23, 2012 at 3:03 PM, Daniel Veillard veill...@redhat.com wrote:
 On Wed, Aug 22, 2012 at 10:40:20PM +0200, Johan Corveleyn wrote:
 On Fri, Aug 17, 2012 at 10:32 PM, Johan Corveleyn jcor...@gmail.com wrote:
  On Fri, Feb 24, 2012 at 2:14 PM, Johan Corveleyn jcor...@gmail.com wrote:
  ...
  I'm running into a non-determinist error with a schema even though I
  don't think it's non-determinist (and both XSV and Xerces agree with
  me; they too have no problem with the schema). I have reduced my
  test-case to a simple example, see below.
 
  On Tue, Feb 28, 2012 at 6:00 AM, Daniel Veillard veill...@redhat.com 
  wrote:
  ...
   Well in that case it seems the underlying code is generating a
  wrong automata so it should be a matter of running that minimal
  test case under gdb with the breakpoint appropriately set to find out
  what wrong transition got added ...
 
  I'd like to take a stab at this issue. I've been able to get the
  latest 2.9.0 snapshot (from
  ftp://xmlsoft.org/libxml2/libxml2-git-snapshot.tar.gz) to build in
  Visual Studio 2010. I can still reproduce the issue.
 
  But I need some guidance. What part of the code should I be looking
  at? Where do I have to set the breakpoint appropriately to find out
  the wrong transition that got added?
 
  Alternatively, if you or anyone else on this list can fix the issue
  already, that would be even better :-).
 
  To summarize, the issue is this:
  Given the following schema:
 
  ?xml version=1.0 encoding=UTF-8?
  xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema;
  xs:element name=rules
  xs:complexType
  xs:sequence
  xs:element name=rule 
  minOccurs=0 maxOccurs=unbounded/
  xs:sequence minOccurs=0 
  maxOccurs=1
  xs:element 
  name=specialRule minOccurs=1 maxOccurs=1/
  xs:element name=rule 
  minOccurs=0 maxOccurs=unbounded/
  /xs:sequence
  /xs:sequence
  /xs:complexType
  /xs:element
  /xs:schema
 
  xmllint complains with Schemas parser error : local
  complex type: The content model is not determinist.
  But it isn't.
 
  See also https://bugzilla.gnome.org/show_bug.cgi?id=670865.

 Hi,

 I could really use some guidance here. I've been able to set up
 everything in Visual Studio 2010, and reproduced the issue from within
 the debugger. So I can set a breakpoint etc. But I mostly lack some
 basic knowledge about how this all works.

 Is there some (preferable concise) reading about basic concepts like
 how xml schemas automata work, how these are built, etc? What should
 the automata in this case look like (in terms of the data structures
 inside the code)? How can I see that the automata is non-determinist,
 and what would a determinist automata look like, ... ?

 Johan,

   sorry for the slow answer,

 I will look at this, promise, but all that code is rooted in automata
 theory, there is quite some litterature about it, and well unless you
 go though the process of learning that code and possibly the theory
 behind it, it's not something that can be hacked trivially. Basically
 I run this in debug mode, look at the automata generated, there is pro
 bably an error there and then this need fixing and a lot of checking.
 To be honnest that one of the hardest part of the library to change
 with the core of the parser.
   Theory is usually learnt though the 'Dragon Book', by Aho and Al.
 and the code is actually more complex since using extended automata
 operations not found in basic automata ...

 If you have time looking at this may be interesting, but
 it's really not trivial at least more complex than other parts of the
 code :-)

Thanks for your answer, and for pointing out that it's not so simple
:-). It seems that this is a bit over my head then (I have little clue
about automata theory, so it would probably take me weeks or months to
understand what's going on ...). I hope you can find some time to dig
in further in the not-too-distant future :-). I'm always willing to
help out, test, ... if that would be useful (though my usefulness
might be limited because of my non-understanding of things ...).

Thanks for all your efforts,
-- 
Johan
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmllint reports non-determinist content model for schema

2012-08-23 Thread Johan Corveleyn
On Thu, Aug 23, 2012 at 5:32 PM, Daniel Veillard veill...@redhat.com wrote:
 On Thu, Aug 23, 2012 at 09:03:44PM +0800, Daniel Veillard wrote:
 On Wed, Aug 22, 2012 at 10:40:20PM +0200, Johan Corveleyn wrote:
 [...]
  Is there some (preferable concise) reading about basic concepts like
  how xml schemas automata work, how these are built, etc? What should
  the automata in this case look like (in terms of the data structures
  inside the code)? How can I see that the automata is non-determinist,
  and what would a determinist automata look like, ... ?

 Johan,

   sorry for the slow answer,

 I will look at this, promise, but all that code is rooted in automata
 theory, there is quite some litterature about it, and well unless you
 go though the process of learning that code and possibly the theory
 behind it, it's not something that can be hacked trivially. Basically
 I run this in debug mode, look at the automata generated, there is pro
 bably an error there and then this need fixing and a lot of checking.
 To be honnest that one of the hardest part of the library to change
 with the core of the parser.
   Theory is usually learnt though the 'Dragon Book', by Aho and Al.
 and the code is actually more complex since using extended automata
 operations not found in basic automata ...

 If you have time looking at this may be interesting, but
 it's really not trivial at least more complex than other parts of the
 code :-)

   Okay simce people may get curious:
 1/ I fixed the issue see the tiny patch attached
 2/ following is an explanation of what I did to debug the issue
in case people may want to fix other issues there of if they are
just curious how a developper may spend half an hour of his time :-)

 Steps:
 0/ make minimal xsd and xml the one given were quite good
 1/ think about the pattern that is being expressed, it's
rule * (specialRule rule *) ?
that should be determinist actually so yes that looks like a bug
 2/ run xmllint --schema tst.xsd tst.xml
clearly libxml2 regexp think it's not determinist, and there is
a construction problem as hinted before
 3/ edit xmlregexp.c comment off the 4 debugging macros at the top
recompile xmllint and run it on the example
 4/ start to study the nice output given:

 ---
 thinkpad:~/XML - xmllint --schema tst.xsd tst.xml
 Add trans from 0 to 1  atom: string once 'rule'
 Add trans from 1 to 1  atom: string once 'rule'
 Add trans from 0 to 1 epsilon transition
 Add trans from 1 to 2  atom: string once 'specialRule'
 Add trans from 2 to 3  atom: string once 'rule'
 Add trans from 3 to 3  atom: string once 'rule'
 Add trans from 2 to 3 epsilon transition
 Add trans from 1 to 3 epsilon transition
 Found epsilon trans 1 from 2 to 3
 xmlFAReduceEpsilonTransitions(2, 3)
 State 3 is final, so 2 becomes final
 Add trans from 2 to 3  atom: string once 'rule'
 Found epsilon trans 2 from 1 to 3
 xmlFAReduceEpsilonTransitions(1, 3)
 State 3 is final, so 1 becomes final
 Add trans from 1 to 3  atom: string once 'rule'
 Found epsilon trans 1 from 0 to 1
 xmlFAReduceEpsilonTransitions(0, 1)
 State 1 is final, so 0 becomes final
 Add trans from 0 to 1  atom: string once 'rule'
 Add trans from 0 to 2  atom: string once 'specialRule'
 Add trans from 0 to 3  atom: string once 'rule'
 xmlFAComputesDeterminism
  ctxt: '(null)'
 5 atoms:
  00  atom: string once 'rule'
  01  atom: string once 'rule'
  02  atom: string once 'specialRule'
  03  atom: string once 'rule'
  04  atom: string once 'rule'
 4 states: start: 0
  state: FINAL 0, 5 transitions:
   trans: atom 0, to 1
   trans: removed
   trans: atom 1, to 1
   trans: atom 2, to 2
   trans: atom 4, to 3
  state: FINAL 1, 4 transitions:
   trans: atom 1, to 1
   trans: atom 2, to 2
   trans: removed
   trans: atom 4, to 3
  state: FINAL 2, 3 transitions:
   trans: atom 3, to 3
   trans: removed
   trans: atom 4, to 3
  state: FINAL 3, 1 transitions:
   trans: atom 4, to 3
 0 counters:
 Final: 4 states
 Final: 2 atoms
 Indet: state 0 trans 4, atom 4 to 3 : 0 to 3
previous to is 2
 tst.xsd:4: element complexType: Schemas parser error : local complex
 type: The content model is not determinist.
 

 5/ make the graph of the automata as it is created and then transformed
by epsilon rules reductions, c.f. the picture P1020568.JPG attached
something is wrong when adding the 3rd epsilon transition from state
1 to state 3, as the indeterminism is created there, suddenly a rule
while in state 0 or 1 could be consumed to go to 1 or to 3.

 6/ there is a need to separate the state from the end of the sequence
from state 3 to avoid the problem

 7/ make the patch adding an extra state at end of 

Re: [xml] xmllint reports non-determinist content model for schema

2012-08-23 Thread Johan Corveleyn
On Fri, Aug 24, 2012 at 12:15 AM, Johan Corveleyn jcor...@gmail.com wrote:
[...]
 I'll give your patch a try on my real-world sample (from which the
 rules example was deduced), just to be sure.

And it works perfectly. Thanks again, you made my day :-).

-- 
Johan
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmllint reports non-determinist content model for schema

2012-08-22 Thread Johan Corveleyn
On Fri, Aug 17, 2012 at 10:32 PM, Johan Corveleyn jcor...@gmail.com wrote:
 On Fri, Feb 24, 2012 at 2:14 PM, Johan Corveleyn jcor...@gmail.com wrote:
 ...
 I'm running into a non-determinist error with a schema even though I
 don't think it's non-determinist (and both XSV and Xerces agree with
 me; they too have no problem with the schema). I have reduced my
 test-case to a simple example, see below.

 On Tue, Feb 28, 2012 at 6:00 AM, Daniel Veillard veill...@redhat.com wrote:
 ...
  Well in that case it seems the underlying code is generating a
 wrong automata so it should be a matter of running that minimal
 test case under gdb with the breakpoint appropriately set to find out
 what wrong transition got added ...

 I'd like to take a stab at this issue. I've been able to get the
 latest 2.9.0 snapshot (from
 ftp://xmlsoft.org/libxml2/libxml2-git-snapshot.tar.gz) to build in
 Visual Studio 2010. I can still reproduce the issue.

 But I need some guidance. What part of the code should I be looking
 at? Where do I have to set the breakpoint appropriately to find out
 the wrong transition that got added?

 Alternatively, if you or anyone else on this list can fix the issue
 already, that would be even better :-).

 To summarize, the issue is this:
 Given the following schema:

 ?xml version=1.0 encoding=UTF-8?
 xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema;
 xs:element name=rules
 xs:complexType
 xs:sequence
 xs:element name=rule 
 minOccurs=0 maxOccurs=unbounded/
 xs:sequence minOccurs=0 
 maxOccurs=1
 xs:element 
 name=specialRule minOccurs=1 maxOccurs=1/
 xs:element name=rule 
 minOccurs=0 maxOccurs=unbounded/
 /xs:sequence
 /xs:sequence
 /xs:complexType
 /xs:element
 /xs:schema

 xmllint complains with Schemas parser error : local
 complex type: The content model is not determinist.
 But it isn't.

 See also https://bugzilla.gnome.org/show_bug.cgi?id=670865.

Hi,

I could really use some guidance here. I've been able to set up
everything in Visual Studio 2010, and reproduced the issue from within
the debugger. So I can set a breakpoint etc. But I mostly lack some
basic knowledge about how this all works.

Is there some (preferable concise) reading about basic concepts like
how xml schemas automata work, how these are built, etc? What should
the automata in this case look like (in terms of the data structures
inside the code)? How can I see that the automata is non-determinist,
and what would a determinist automata look like, ... ?

A bit clueless,
-- 
Johan
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmllint reports non-determinist content model for schema

2012-08-17 Thread Johan Corveleyn
On Fri, Feb 24, 2012 at 2:14 PM, Johan Corveleyn jcor...@gmail.com wrote:
...
 I'm running into a non-determinist error with a schema even though I
 don't think it's non-determinist (and both XSV and Xerces agree with
 me; they too have no problem with the schema). I have reduced my
 test-case to a simple example, see below.

On Tue, Feb 28, 2012 at 6:00 AM, Daniel Veillard veill...@redhat.com wrote:
...
  Well in that case it seems the underlying code is generating a
 wrong automata so it should be a matter of running that minimal
 test case under gdb with the breakpoint appropriately set to find out
 what wrong transition got added ...

I'd like to take a stab at this issue. I've been able to get the
latest 2.9.0 snapshot (from
ftp://xmlsoft.org/libxml2/libxml2-git-snapshot.tar.gz) to build in
Visual Studio 2010. I can still reproduce the issue.

But I need some guidance. What part of the code should I be looking
at? Where do I have to set the breakpoint appropriately to find out
the wrong transition that got added?

Alternatively, if you or anyone else on this list can fix the issue
already, that would be even better :-).

To summarize, the issue is this:
 Given the following schema:

 ?xml version=1.0 encoding=UTF-8?
 xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema;
 xs:element name=rules
 xs:complexType
 xs:sequence
 xs:element name=rule minOccurs=0 
 maxOccurs=unbounded/
 xs:sequence minOccurs=0 
 maxOccurs=1
 xs:element 
 name=specialRule minOccurs=1 maxOccurs=1/
 xs:element name=rule 
 minOccurs=0 maxOccurs=unbounded/
 /xs:sequence
 /xs:sequence
 /xs:complexType
 /xs:element
 /xs:schema

 xmllint complains with Schemas parser error : local
 complex type: The content model is not determinist.
 But it isn't.

See also https://bugzilla.gnome.org/show_bug.cgi?id=670865.

-- 
Johan
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmllint reports non-determinist content model for schema

2012-02-27 Thread Johan Corveleyn
Thanks for confirming. That's already a big help :-).

Too bad that there is no other way to express this in XML Schema,
which works with xmllint.

I'll file an issue in the issue tracker, and hopefully someone will
find the time to fix this some day.

Cheers,
-- 
Johan

On Fri, Feb 24, 2012 at 2:58 PM, Pete Cordell petexml...@codalogic.com wrote:
 FWIW, the schema looks OK to me and neither Visual Studio or the W3C's XSV
 seem to report an error, so it does look like a libxml2 bug.

 And I can't think of another way of expressing what you want that isn't
 truly non-deterministic.

 HTH a bit!

 Pete Cordell
 Codalogic Ltd
 Interface XML to C++ the easy way using C++ XML
 data binding to convert XSD schemas to C++ classes.
 Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
 for more info

 - Original Message - From: Johan Corveleyn jcor...@gmail.com
 To: xml@gnome.org
 Sent: Friday, February 24, 2012 1:14 PM
 Subject: [xml] xmllint reports non-determinist content model for schema


 Hi,

 This is my first post to this list. I searched the mailing list
 archives and bugzilla, but couldn't find the exact issue I'm
 confronted with (if I missed something, please point me to it).

 I'm running into a non-determinist error with a schema even though I
 don't think it's non-determinist (and both XSV and Xerces agree with
 me; they too have no problem with the schema). I have reduced my
 test-case to a simple example, see below.

 Given the following schema:

 ?xml version=1.0 encoding=UTF-8?
 xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema;
 xs:element name=rules
 xs:complexType
 xs:sequence
 xs:element name=rule minOccurs=0 maxOccurs=unbounded/
 xs:sequence minOccurs=0 maxOccurs=1
 xs:element name=specialRule minOccurs=1 maxOccurs=1/
 xs:element name=rule minOccurs=0 maxOccurs=unbounded/
 /xs:sequence
 /xs:sequence
 /xs:complexType
 /xs:element
 /xs:schema

 xmllint version 20708 complains with Schemas parser error : local
 complex type: The content model is not determinist.

 The intention is to express that there can be any number of rule
 elements, and there can be at most one specialRule (at any position
 in between, before, or after the rules). So the following xml's are
 all valid:

 ?xml version=1.0 encoding=UTF-8?
 rules
 rule/
 rule/
 specialRule/
 rule/
 /rules

 ?xml version=1.0 encoding=UTF-8?
 rules
 specialRule/
 /rules

 ?xml version=1.0 encoding=UTF-8?
 rules
 specialRule/
 rule/
 rule/
 rule/
 /rules

 ?xml version=1.0 encoding=UTF-8?
 rules
 rule/
 rule/
 rule/
 /rules

 But this one isn't (two specialRules):

 ?xml version=1.0 encoding=UTF-8?
 rules
 specialRule/
 rule/
 rule/
 specialRule/
 rule/
 /rules



 Is this a bug in libxml2?

 And whether or not it's a bug: any workarounds? Can I write my schema
 in another way to make xmllint succeed, and still express the same
 constraints?

 --
 Johan
 ___
 xml mailing list, project page  http://xmlsoft.org/
 xml@gnome.org
 http://mail.gnome.org/mailman/listinfo/xml


___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmllint reports non-determinist content model for schema

2012-02-27 Thread Pete Cordell
I think it's fair to say that Daniel isn't a great fan is XML XSD Schema, so 
I imagine it won't be fixed too quickly.  I think libxml2's support for 
Relax NG is better.  It might be worth seeing if you can do what you want 
with that.  I've never tried it, but by all accounts Trang should be able to 
give you a start at converting your XSD to Relax NG if your schema is 
non-trivial.


HTH,

Pete Cordell
Codalogic Ltd
Interface XML to C++ the easy way using C++ XML
data binding to convert XSD schemas to C++ classes.
Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
for more info
- Original Message - 
From: Johan Corveleyn jcor...@gmail.com

To: Pete Cordell petexml...@codalogic.com
Cc: xml@gnome.org
Sent: Monday, February 27, 2012 8:29 AM
Subject: Re: [xml] xmllint reports non-determinist content model for schema


Thanks for confirming. That's already a big help :-).

Too bad that there is no other way to express this in XML Schema,
which works with xmllint.

I'll file an issue in the issue tracker, and hopefully someone will
find the time to fix this some day.

Cheers,
--
Johan

On Fri, Feb 24, 2012 at 2:58 PM, Pete Cordell petexml...@codalogic.com 
wrote:

FWIW, the schema looks OK to me and neither Visual Studio or the W3C's XSV
seem to report an error, so it does look like a libxml2 bug.

And I can't think of another way of expressing what you want that isn't
truly non-deterministic.

HTH a bit!

Pete Cordell
Codalogic Ltd
Interface XML to C++ the easy way using C++ XML
data binding to convert XSD schemas to C++ classes.
Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
for more info

- Original Message - From: Johan Corveleyn jcor...@gmail.com
To: xml@gnome.org
Sent: Friday, February 24, 2012 1:14 PM
Subject: [xml] xmllint reports non-determinist content model for schema



Hi,

This is my first post to this list. I searched the mailing list
archives and bugzilla, but couldn't find the exact issue I'm
confronted with (if I missed something, please point me to it).

I'm running into a non-determinist error with a schema even though I
don't think it's non-determinist (and both XSV and Xerces agree with
me; they too have no problem with the schema). I have reduced my
test-case to a simple example, see below.

Given the following schema:

?xml version=1.0 encoding=UTF-8?
xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema;
xs:element name=rules
xs:complexType
xs:sequence
xs:element name=rule minOccurs=0 maxOccurs=unbounded/
xs:sequence minOccurs=0 maxOccurs=1
xs:element name=specialRule minOccurs=1 maxOccurs=1/
xs:element name=rule minOccurs=0 maxOccurs=unbounded/
/xs:sequence
/xs:sequence
/xs:complexType
/xs:element
/xs:schema

xmllint version 20708 complains with Schemas parser error : local
complex type: The content model is not determinist.

The intention is to express that there can be any number of rule
elements, and there can be at most one specialRule (at any position
in between, before, or after the rules). So the following xml's are
all valid:

?xml version=1.0 encoding=UTF-8?
rules
rule/
rule/
specialRule/
rule/
/rules

?xml version=1.0 encoding=UTF-8?
rules
specialRule/
/rules

?xml version=1.0 encoding=UTF-8?
rules
specialRule/
rule/
rule/
rule/
/rules

?xml version=1.0 encoding=UTF-8?
rules
rule/
rule/
rule/
/rules

But this one isn't (two specialRules):

?xml version=1.0 encoding=UTF-8?
rules
specialRule/
rule/
rule/
specialRule/
rule/
/rules



Is this a bug in libxml2?

And whether or not it's a bug: any workarounds? Can I write my schema
in another way to make xmllint succeed, and still express the same
constraints?

--
Johan
___
xml mailing list, project page http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml





___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmllint reports non-determinist content model for schema

2012-02-24 Thread Pete Cordell
FWIW, the schema looks OK to me and neither Visual Studio or the W3C's XSV 
seem to report an error, so it does look like a libxml2 bug.


And I can't think of another way of expressing what you want that isn't 
truly non-deterministic.


HTH a bit!

Pete Cordell
Codalogic Ltd
Interface XML to C++ the easy way using C++ XML
data binding to convert XSD schemas to C++ classes.
Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
for more info

- Original Message - 
From: Johan Corveleyn jcor...@gmail.com

To: xml@gnome.org
Sent: Friday, February 24, 2012 1:14 PM
Subject: [xml] xmllint reports non-determinist content model for schema



Hi,

This is my first post to this list. I searched the mailing list
archives and bugzilla, but couldn't find the exact issue I'm
confronted with (if I missed something, please point me to it).

I'm running into a non-determinist error with a schema even though I
don't think it's non-determinist (and both XSV and Xerces agree with
me; they too have no problem with the schema). I have reduced my
test-case to a simple example, see below.

Given the following schema:

?xml version=1.0 encoding=UTF-8?
xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema;
xs:element name=rules
xs:complexType
xs:sequence
xs:element name=rule minOccurs=0 maxOccurs=unbounded/
xs:sequence minOccurs=0 maxOccurs=1
xs:element name=specialRule minOccurs=1 maxOccurs=1/
xs:element name=rule minOccurs=0 maxOccurs=unbounded/
/xs:sequence
/xs:sequence
/xs:complexType
/xs:element
/xs:schema

xmllint version 20708 complains with Schemas parser error : local
complex type: The content model is not determinist.

The intention is to express that there can be any number of rule
elements, and there can be at most one specialRule (at any position
in between, before, or after the rules). So the following xml's are
all valid:

?xml version=1.0 encoding=UTF-8?
rules
rule/
rule/
specialRule/
rule/
/rules

?xml version=1.0 encoding=UTF-8?
rules
specialRule/
/rules

?xml version=1.0 encoding=UTF-8?
rules
specialRule/
rule/
rule/
rule/
/rules

?xml version=1.0 encoding=UTF-8?
rules
rule/
rule/
rule/
/rules

But this one isn't (two specialRules):

?xml version=1.0 encoding=UTF-8?
rules
specialRule/
rule/
rule/
specialRule/
rule/
/rules



Is this a bug in libxml2?

And whether or not it's a bug: any workarounds? Can I write my schema
in another way to make xmllint succeed, and still express the same
constraints?

--
Johan
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml 


___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml