diff --git a/ChangeLog b/ChangeLog index 8953de06..3f8e49c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Apr 17 18:26:07 CEST 2002 Daniel Veillard + + * xmlregexp.c xmlschemas.c include/libxml/xmlautomata.h: more work + on the automata interfaces and debug of counted choices + * test/schemas/* result/schemas/*: added a number of tests + Wed Apr 17 11:03:03 CEST 2002 Daniel Veillard * xmlschemas.c xmlschemastypes.c include/libxml/xmlschemas.h: diff --git a/include/libxml/xmlautomata.h b/include/libxml/xmlautomata.h index ad3acf7d..853acc4f 100644 --- a/include/libxml/xmlautomata.h +++ b/include/libxml/xmlautomata.h @@ -63,7 +63,17 @@ xmlAutomataStatePtr xmlAutomataNewCountTrans(xmlAutomataPtr am, xmlAutomataStatePtr xmlAutomataNewEpsilon (xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to); -int xmlAutomataNewCounter (xmlAutomataPtr am); +xmlAutomataStatePtr xmlAutomataNewCountedTrans(xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + int counter); +xmlAutomataStatePtr xmlAutomataNewCounterTrans(xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + int counter); +int xmlAutomataNewCounter (xmlAutomataPtr am, + int min, + int max); xmlRegexpPtr xmlAutomataCompile (xmlAutomataPtr am); diff --git a/result/schemas/choice_0_5 b/result/schemas/choice_0_5 new file mode 100644 index 00000000..acaaddd8 --- /dev/null +++ b/result/schemas/choice_0_5 @@ -0,0 +1 @@ +./test/schemas/choice_5.xml fails to validate diff --git a/result/schemas/choice_0_5.err b/result/schemas/choice_0_5.err new file mode 100644 index 00000000..a4025c9d --- /dev/null +++ b/result/schemas/choice_0_5.err @@ -0,0 +1,24 @@ +Type of choice 3 : ./test/schemas/choice_0.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_0.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_0.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_0.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +4 states: + state: 0, 2 transitions: + trans: atom 0, to 2 + trans: atom 1, to 3 + state: FINAL 1, 0 transitions: + state: FINAL 2, 1 transitions: + trans: removed + state: FINAL 3, 1 transitions: + trans: removed +0 counters: +Building content model for a +Building content model for b +xmlSchemaValidateCallback: a, a, a +Element doc content check failed diff --git a/result/schemas/choice_0_6 b/result/schemas/choice_0_6 new file mode 100644 index 00000000..ee4ceaef --- /dev/null +++ b/result/schemas/choice_0_6 @@ -0,0 +1 @@ +./test/schemas/choice_6.xml fails to validate diff --git a/result/schemas/choice_0_6.err b/result/schemas/choice_0_6.err new file mode 100644 index 00000000..a4025c9d --- /dev/null +++ b/result/schemas/choice_0_6.err @@ -0,0 +1,24 @@ +Type of choice 3 : ./test/schemas/choice_0.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_0.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_0.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_0.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +4 states: + state: 0, 2 transitions: + trans: atom 0, to 2 + trans: atom 1, to 3 + state: FINAL 1, 0 transitions: + state: FINAL 2, 1 transitions: + trans: removed + state: FINAL 3, 1 transitions: + trans: removed +0 counters: +Building content model for a +Building content model for b +xmlSchemaValidateCallback: a, a, a +Element doc content check failed diff --git a/result/schemas/choice_1_0 b/result/schemas/choice_1_0 new file mode 100644 index 00000000..eda062ec --- /dev/null +++ b/result/schemas/choice_1_0 @@ -0,0 +1 @@ +./test/schemas/choice_0.xml validates diff --git a/result/schemas/choice_1_0.err b/result/schemas/choice_1_0.err new file mode 100644 index 00000000..306b246f --- /dev/null +++ b/result/schemas/choice_1_0.err @@ -0,0 +1,25 @@ +Type of choice 3 : ./test/schemas/choice_1.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_1.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_1.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_1.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +4 states: + state: FINAL 0, 3 transitions: + trans: atom 0, to 2 + trans: atom 1, to 3 + trans: removed + state: FINAL 1, 0 transitions: + state: FINAL 2, 1 transitions: + trans: removed + state: FINAL 3, 1 transitions: + trans: removed +0 counters: +Building content model for a +Building content model for b +xmlSchemaValidateCallback: a, a, a +Element doc content check succeeded diff --git a/result/schemas/choice_1_1 b/result/schemas/choice_1_1 new file mode 100644 index 00000000..e4338ded --- /dev/null +++ b/result/schemas/choice_1_1 @@ -0,0 +1 @@ +./test/schemas/choice_1.xml validates diff --git a/result/schemas/choice_1_1.err b/result/schemas/choice_1_1.err new file mode 100644 index 00000000..d9e0051e --- /dev/null +++ b/result/schemas/choice_1_1.err @@ -0,0 +1,25 @@ +Type of choice 3 : ./test/schemas/choice_1.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_1.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_1.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_1.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +4 states: + state: FINAL 0, 3 transitions: + trans: atom 0, to 2 + trans: atom 1, to 3 + trans: removed + state: FINAL 1, 0 transitions: + state: FINAL 2, 1 transitions: + trans: removed + state: FINAL 3, 1 transitions: + trans: removed +0 counters: +Building content model for a +Building content model for b +xmlSchemaValidateCallback: b, b, b +Element doc content check succeeded diff --git a/result/schemas/choice_1_2 b/result/schemas/choice_1_2 new file mode 100644 index 00000000..40713158 --- /dev/null +++ b/result/schemas/choice_1_2 @@ -0,0 +1 @@ +./test/schemas/choice_2.xml fails to validate diff --git a/result/schemas/choice_1_2.err b/result/schemas/choice_1_2.err new file mode 100644 index 00000000..3d3bd985 --- /dev/null +++ b/result/schemas/choice_1_2.err @@ -0,0 +1,25 @@ +Type of choice 3 : ./test/schemas/choice_1.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_1.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_1.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_1.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +4 states: + state: FINAL 0, 3 transitions: + trans: atom 0, to 2 + trans: atom 1, to 3 + trans: removed + state: FINAL 1, 0 transitions: + state: FINAL 2, 1 transitions: + trans: removed + state: FINAL 3, 1 transitions: + trans: removed +0 counters: +Building content model for a +Building content model for b +xmlSchemaValidateCallback: a, a, a +Element doc content check failed diff --git a/result/schemas/choice_1_3 b/result/schemas/choice_1_3 new file mode 100644 index 00000000..bef604b9 --- /dev/null +++ b/result/schemas/choice_1_3 @@ -0,0 +1 @@ +./test/schemas/choice_3.xml fails to validate diff --git a/result/schemas/choice_1_3.err b/result/schemas/choice_1_3.err new file mode 100644 index 00000000..3d3bd985 --- /dev/null +++ b/result/schemas/choice_1_3.err @@ -0,0 +1,25 @@ +Type of choice 3 : ./test/schemas/choice_1.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_1.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_1.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_1.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +4 states: + state: FINAL 0, 3 transitions: + trans: atom 0, to 2 + trans: atom 1, to 3 + trans: removed + state: FINAL 1, 0 transitions: + state: FINAL 2, 1 transitions: + trans: removed + state: FINAL 3, 1 transitions: + trans: removed +0 counters: +Building content model for a +Building content model for b +xmlSchemaValidateCallback: a, a, a +Element doc content check failed diff --git a/result/schemas/choice_1_4 b/result/schemas/choice_1_4 new file mode 100644 index 00000000..36b3827b --- /dev/null +++ b/result/schemas/choice_1_4 @@ -0,0 +1 @@ +./test/schemas/choice_4.xml validates diff --git a/result/schemas/choice_1_4.err b/result/schemas/choice_1_4.err new file mode 100644 index 00000000..610e947d --- /dev/null +++ b/result/schemas/choice_1_4.err @@ -0,0 +1,24 @@ +Type of choice 3 : ./test/schemas/choice_1.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_1.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_1.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_1.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +4 states: + state: FINAL 0, 3 transitions: + trans: atom 0, to 2 + trans: atom 1, to 3 + trans: removed + state: FINAL 1, 0 transitions: + state: FINAL 2, 1 transitions: + trans: removed + state: FINAL 3, 1 transitions: + trans: removed +0 counters: +Building content model for a +Building content model for b +Element doc content check succeeded diff --git a/result/schemas/choice_1_5 b/result/schemas/choice_1_5 new file mode 100644 index 00000000..acaaddd8 --- /dev/null +++ b/result/schemas/choice_1_5 @@ -0,0 +1 @@ +./test/schemas/choice_5.xml fails to validate diff --git a/result/schemas/choice_1_5.err b/result/schemas/choice_1_5.err new file mode 100644 index 00000000..3d3bd985 --- /dev/null +++ b/result/schemas/choice_1_5.err @@ -0,0 +1,25 @@ +Type of choice 3 : ./test/schemas/choice_1.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_1.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_1.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_1.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +4 states: + state: FINAL 0, 3 transitions: + trans: atom 0, to 2 + trans: atom 1, to 3 + trans: removed + state: FINAL 1, 0 transitions: + state: FINAL 2, 1 transitions: + trans: removed + state: FINAL 3, 1 transitions: + trans: removed +0 counters: +Building content model for a +Building content model for b +xmlSchemaValidateCallback: a, a, a +Element doc content check failed diff --git a/result/schemas/choice_1_6 b/result/schemas/choice_1_6 new file mode 100644 index 00000000..ee4ceaef --- /dev/null +++ b/result/schemas/choice_1_6 @@ -0,0 +1 @@ +./test/schemas/choice_6.xml fails to validate diff --git a/result/schemas/choice_1_6.err b/result/schemas/choice_1_6.err new file mode 100644 index 00000000..3d3bd985 --- /dev/null +++ b/result/schemas/choice_1_6.err @@ -0,0 +1,25 @@ +Type of choice 3 : ./test/schemas/choice_1.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_1.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_1.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_1.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +4 states: + state: FINAL 0, 3 transitions: + trans: atom 0, to 2 + trans: atom 1, to 3 + trans: removed + state: FINAL 1, 0 transitions: + state: FINAL 2, 1 transitions: + trans: removed + state: FINAL 3, 1 transitions: + trans: removed +0 counters: +Building content model for a +Building content model for b +xmlSchemaValidateCallback: a, a, a +Element doc content check failed diff --git a/result/schemas/choice_2_0 b/result/schemas/choice_2_0 new file mode 100644 index 00000000..eda062ec --- /dev/null +++ b/result/schemas/choice_2_0 @@ -0,0 +1 @@ +./test/schemas/choice_0.xml validates diff --git a/result/schemas/choice_2_0.err b/result/schemas/choice_2_0.err new file mode 100644 index 00000000..9596021e --- /dev/null +++ b/result/schemas/choice_2_0.err @@ -0,0 +1,40 @@ +Type of choice 3 : ./test/schemas/choice_2.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_2.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_2.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +5 states: + state: 0, 2 transitions: + trans: atom 0, to 3 + trans: atom 1, to 4 + state: FINAL 1, 0 transitions: + state: 2, 4 transitions: + trans: removed + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + state: 3, 6 transitions: + trans: removed + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + state: 4, 6 transitions: + trans: removed + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 +1 counters: + 0: min 0 max 2 +Building content model for a +Building content model for b +xmlSchemaValidateCallback: a, a, a +Element doc content check succeeded diff --git a/result/schemas/choice_2_1 b/result/schemas/choice_2_1 new file mode 100644 index 00000000..e69de29b diff --git a/result/schemas/choice_2_1.err b/result/schemas/choice_2_1.err new file mode 100644 index 00000000..393f6ff8 --- /dev/null +++ b/result/schemas/choice_2_1.err @@ -0,0 +1,42 @@ +Type of choice 3 : ./test/schemas/choice_2.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_2.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_2.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +5 states: + state: 0, 2 transitions: + trans: atom 0, to 3 + trans: atom 1, to 4 + state: FINAL 1, 0 transitions: + state: 2, 4 transitions: + trans: removed + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + state: 3, 6 transitions: + trans: removed + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + state: 4, 6 transitions: + trans: removed + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 +1 counters: + 0: min 0 max 2 +Building content model for a +Building content model for b +xmlSchemaValidateCallback: b, b, b +Element doc content check succeeded +(nil) : Freed() +xmlMallocBreakpoint reached on block 0 diff --git a/result/schemas/choice_2_2 b/result/schemas/choice_2_2 new file mode 100644 index 00000000..c58e1549 --- /dev/null +++ b/result/schemas/choice_2_2 @@ -0,0 +1 @@ +./test/schemas/choice_2.xml validates diff --git a/result/schemas/choice_2_2.err b/result/schemas/choice_2_2.err new file mode 100644 index 00000000..041d0178 --- /dev/null +++ b/result/schemas/choice_2_2.err @@ -0,0 +1,41 @@ +Type of choice 3 : ./test/schemas/choice_2.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_2.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_2.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +5 states: + state: 0, 2 transitions: + trans: atom 0, to 3 + trans: atom 1, to 4 + state: FINAL 1, 0 transitions: + state: 2, 4 transitions: + trans: removed + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + state: 3, 6 transitions: + trans: removed + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + state: 4, 6 transitions: + trans: removed + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 +1 counters: + 0: min 0 max 2 +Building content model for a +Building content model for b +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: b, b, b +Element doc content check succeeded diff --git a/result/schemas/choice_2_3 b/result/schemas/choice_2_3 new file mode 100644 index 00000000..1058f7e7 --- /dev/null +++ b/result/schemas/choice_2_3 @@ -0,0 +1 @@ +./test/schemas/choice_3.xml validates diff --git a/result/schemas/choice_2_3.err b/result/schemas/choice_2_3.err new file mode 100644 index 00000000..1d2e304c --- /dev/null +++ b/result/schemas/choice_2_3.err @@ -0,0 +1,41 @@ +Type of choice 3 : ./test/schemas/choice_2.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_2.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_2.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +5 states: + state: 0, 2 transitions: + trans: atom 0, to 3 + trans: atom 1, to 4 + state: FINAL 1, 0 transitions: + state: 2, 4 transitions: + trans: removed + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + state: 3, 6 transitions: + trans: removed + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + state: 4, 6 transitions: + trans: removed + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 +1 counters: + 0: min 0 max 2 +Building content model for a +Building content model for b +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: a, a, a +Element doc content check succeeded diff --git a/result/schemas/choice_2_4 b/result/schemas/choice_2_4 new file mode 100644 index 00000000..0643e3b2 --- /dev/null +++ b/result/schemas/choice_2_4 @@ -0,0 +1 @@ +./test/schemas/choice_4.xml fails to validate diff --git a/result/schemas/choice_2_4.err b/result/schemas/choice_2_4.err new file mode 100644 index 00000000..d4ef0434 --- /dev/null +++ b/result/schemas/choice_2_4.err @@ -0,0 +1,39 @@ +Type of choice 3 : ./test/schemas/choice_2.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_2.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_2.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +5 states: + state: 0, 2 transitions: + trans: atom 0, to 3 + trans: atom 1, to 4 + state: FINAL 1, 0 transitions: + state: 2, 4 transitions: + trans: removed + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + state: 3, 6 transitions: + trans: removed + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + state: 4, 6 transitions: + trans: removed + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 +1 counters: + 0: min 0 max 2 +Building content model for a +Building content model for b +Element doc content check failed diff --git a/result/schemas/choice_2_5 b/result/schemas/choice_2_5 new file mode 100644 index 00000000..67e79baf --- /dev/null +++ b/result/schemas/choice_2_5 @@ -0,0 +1 @@ +./test/schemas/choice_5.xml validates diff --git a/result/schemas/choice_2_5.err b/result/schemas/choice_2_5.err new file mode 100644 index 00000000..e2fc216a --- /dev/null +++ b/result/schemas/choice_2_5.err @@ -0,0 +1,42 @@ +Type of choice 3 : ./test/schemas/choice_2.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_2.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_2.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +5 states: + state: 0, 2 transitions: + trans: atom 0, to 3 + trans: atom 1, to 4 + state: FINAL 1, 0 transitions: + state: 2, 4 transitions: + trans: removed + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + state: 3, 6 transitions: + trans: removed + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + state: 4, 6 transitions: + trans: removed + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 +1 counters: + 0: min 0 max 2 +Building content model for a +Building content model for b +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: b, b, b +xmlSchemaValidateCallback: a, a, a +Element doc content check succeeded diff --git a/result/schemas/choice_2_6 b/result/schemas/choice_2_6 new file mode 100644 index 00000000..ee4ceaef --- /dev/null +++ b/result/schemas/choice_2_6 @@ -0,0 +1 @@ +./test/schemas/choice_6.xml fails to validate diff --git a/result/schemas/choice_2_6.err b/result/schemas/choice_2_6.err new file mode 100644 index 00000000..2d03b134 --- /dev/null +++ b/result/schemas/choice_2_6.err @@ -0,0 +1,54 @@ +Type of choice 3 : ./test/schemas/choice_2.xsd:6 :elements +Type of sequence 2 : ./test/schemas/choice_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/choice_2.xsd:4 :elements +Type of sequence 2 : ./test/schemas/choice_2.xsd:5 :elements +Building content model for doc +Content model of doc: + regexp: '(null)' +2 atoms: + 00 atom: string once 'a' + 01 atom: string once 'b' +5 states: + state: 0, 2 transitions: + trans: atom 0, to 3 + trans: atom 1, to 4 + state: FINAL 1, 0 transitions: + state: 2, 4 transitions: + trans: removed + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + state: 3, 6 transitions: + trans: removed + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + state: 4, 6 transitions: + trans: removed + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 + trans: count based 0, epsilon to 1 + trans: counted 0, atom 0, to 3 + trans: counted 0, atom 1, to 4 +1 counters: + 0: min 0 max 2 +Building content model for a +Building content model for b +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: b, b, b +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: b, b, b +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: a, a, a +Element doc content check failed diff --git a/test/schemas/choice_0.xsd b/test/schemas/choice_0.xsd index 7f690f47..1491b6b9 100644 --- a/test/schemas/choice_0.xsd +++ b/test/schemas/choice_0.xsd @@ -3,7 +3,7 @@ - + diff --git a/test/schemas/choice_1.xsd b/test/schemas/choice_1.xsd new file mode 100644 index 00000000..00614d09 --- /dev/null +++ b/test/schemas/choice_1.xsd @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/test/schemas/choice_2.xsd b/test/schemas/choice_2.xsd new file mode 100644 index 00000000..9f2b094c --- /dev/null +++ b/test/schemas/choice_2.xsd @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/test/schemas/choice_5.xml b/test/schemas/choice_5.xml new file mode 100644 index 00000000..3345a68b --- /dev/null +++ b/test/schemas/choice_5.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/test/schemas/choice_6.xml b/test/schemas/choice_6.xml new file mode 100644 index 00000000..394153dc --- /dev/null +++ b/test/schemas/choice_6.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/xmlregexp.c b/xmlregexp.c index 1139e158..31657ea8 100644 --- a/xmlregexp.c +++ b/xmlregexp.c @@ -1144,20 +1144,41 @@ xmlFAReduceEpsilonTransitions(xmlRegParserCtxtPtr ctxt, int fromnr, * Don't remove counted transitions * Don't loop either */ - if ((to->trans[transnr].count < 0) && - (to->trans[transnr].to != fromnr)) { + if (to->trans[transnr].to != fromnr) { + if (to->trans[transnr].count >= 0) { + int newto = to->trans[transnr].to; + + xmlRegStateAddTrans(ctxt, from, NULL, + ctxt->states[newto], + -1, to->trans[transnr].count); + } else { #ifdef DEBUG_REGEXP_GRAPH - printf("Found epsilon trans %d from %d to %d\n", - transnr, tonr, to->trans[transnr].to); + printf("Found epsilon trans %d from %d to %d\n", + transnr, tonr, to->trans[transnr].to); #endif - xmlFAReduceEpsilonTransitions(ctxt, fromnr, - to->trans[transnr].to, counter); + if (to->trans[transnr].counter >= 0) { + xmlFAReduceEpsilonTransitions(ctxt, fromnr, + to->trans[transnr].to, + to->trans[transnr].counter); + } else { + xmlFAReduceEpsilonTransitions(ctxt, fromnr, + to->trans[transnr].to, + counter); + } + } } } else { int newto = to->trans[transnr].to; - xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom, - ctxt->states[newto], counter, -1); + if (to->trans[transnr].counter >= 0) { + xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom, + ctxt->states[newto], + to->trans[transnr].counter, -1); + } else { + xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom, + ctxt->states[newto], counter, -1); + } + } } to->mark = XML_REGEXP_MARK_NORMAL; @@ -1966,7 +1987,7 @@ xmlRegExecPushString(xmlRegExecCtxtPtr exec, const xmlChar *value, * still have epsilon like transition for counted transitions * on counters, in that case don't break too early. */ - if (value == NULL) + if ((value == NULL) && (exec->counts == NULL)) goto rollback; exec->transcount = 0; @@ -2612,7 +2633,7 @@ xmlFAParseCharClassEsc(xmlRegParserCtxtPtr ctxt) { } else if ((cur == 's') || (cur == 'S') || (cur == 'i') || (cur == 'I') || (cur == 'c') || (cur == 'C') || (cur == 'd') || (cur == 'D') || (cur == 'w') || (cur == 'W')) { - xmlRegAtomType type; + xmlRegAtomType type = XML_REGEXP_ANYSPACE; switch (cur) { case 's': @@ -3444,9 +3465,78 @@ xmlAutomataNewEpsilon(xmlAutomataPtr am, xmlAutomataStatePtr from, return(to); } -#if 0 -int xmlAutomataNewCounter (xmlAutomataPtr am); -#endif +/** + * xmlAutomataNewCounter: + * @am: an automata + * @min: the minimal value on the counter + * @max: the maximal value on the counter + * + * Create a new counter + * + * Returns the counter number or -1 in case of error + */ +int +xmlAutomataNewCounter(xmlAutomataPtr am, int min, int max) { + int ret; + + if (am == NULL) + return(-1); + + ret = xmlRegGetCounter(am); + if (ret < 0) + return(-1); + am->counters[ret].min = min; + am->counters[ret].max = max; + return(ret); +} + +/** + * xmlAutomataNewCountedTrans: + * @am: an automata + * @from: the starting point of the transition + * @to: the target point of the transition or NULL + * @counter: the counter associated to that transition + * + * If @to is NULL, this create first a new target state in the automata + * and then adds an epsilon transition from the @from state to the target state + * which will increment the counter provided + * + * Returns the target state or NULL in case of error + */ +xmlAutomataStatePtr +xmlAutomataNewCountedTrans(xmlAutomataPtr am, xmlAutomataStatePtr from, + xmlAutomataStatePtr to, int counter) { + if ((am == NULL) || (from == NULL) || (counter < 0)) + return(NULL); + xmlFAGenerateCountedEpsilonTransition(am, from, to, counter); + if (to == NULL) + return(am->state); + return(to); +} + +/** + * xmlAutomataNewCounterTrans: + * @am: an automata + * @from: the starting point of the transition + * @to: the target point of the transition or NULL + * @counter: the counter associated to that transition + * + * If @to is NULL, this create first a new target state in the automata + * and then adds an epsilon transition from the @from state to the target state + * which will be allowed only if the counter is within the right range. + * + * Returns the target state or NULL in case of error + */ +xmlAutomataStatePtr +xmlAutomataNewCounterTrans(xmlAutomataPtr am, xmlAutomataStatePtr from, + xmlAutomataStatePtr to, int counter) { + if ((am == NULL) || (from == NULL) || (counter < 0)) + return(NULL); + xmlFAGenerateCountedTransition(am, from, to, counter); + if (to == NULL) + return(am->state); + return(to); +} /** * xmlAutomataCompile: diff --git a/xmlschemas.c b/xmlschemas.c index 4ccc1f17..e47b3824 100644 --- a/xmlschemas.c +++ b/xmlschemas.c @@ -2995,12 +2995,43 @@ xmlSchemaBuildAContentModel(xmlSchemaTypePtr type, * iterate over the subtypes and remerge the end with an * epsilon transition */ - subtypes = type->subtypes; - while (subtypes != NULL) { - ctxt->state = start; - xmlSchemaBuildAContentModel(subtypes, ctxt, name); - xmlAutomataNewEpsilon(ctxt->am, ctxt->state, end); - subtypes = subtypes->next; + if (type->maxOccurs == 1) { + subtypes = type->subtypes; + while (subtypes != NULL) { + ctxt->state = start; + xmlSchemaBuildAContentModel(subtypes, ctxt, name); + xmlAutomataNewEpsilon(ctxt->am, ctxt->state, end); + subtypes = subtypes->next; + } + } else { + int counter; + xmlAutomataStatePtr hop; + + /* + * use a counter to keep track of the number of transtions + * which went through the choice. + */ + if (type->minOccurs < 1) { + counter = xmlAutomataNewCounter(ctxt->am, 0, + type->maxOccurs - 1); + } else { + counter = xmlAutomataNewCounter(ctxt->am, + type->minOccurs - 1, type->maxOccurs - 1); + } + hop = xmlAutomataNewState(ctxt->am); + + subtypes = type->subtypes; + while (subtypes != NULL) { + ctxt->state = start; + xmlSchemaBuildAContentModel(subtypes, ctxt, name); + xmlAutomataNewEpsilon(ctxt->am, ctxt->state, hop); + subtypes = subtypes->next; + } + xmlAutomataNewCountedTrans(ctxt->am, hop, start, counter); + xmlAutomataNewCounterTrans(ctxt->am, hop, end, counter); + } + if (type->minOccurs == 0) { + xmlAutomataNewEpsilon(ctxt->am, start, end); } ctxt->state = end; break;