imported DTD compatibility test suite
[cxml-rng-test.git] / dtd-split / Compatibility.rng.ssuite
blobf222fe71913a780c9a833ef0b87097f127de1025
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2 <!DOCTYPE testSuite [
4 <!ENTITY rngURI "http://relaxng.org/ns/structure/1.0">
5 <!ENTITY compLibURI "http://relaxng.org/ns/compatibility/datatypes/1.0">
6 <!ENTITY xsdlibURI "http://www.w3.org/2001/XMLSchema-datatypes">
7 ]>
8 <testSuite
9 xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
10 xmlns:rng="&rngURI;"
11 xmlns:foo="foo"
14 <title>RELAX NG DTD Compatibility Test Suite</title>
15 <author>Sun Microsystems</author>
16 <email>kohsuke.kawaguchi@sun.com</email>
17 <documentation>
18 This test suite tests the conformance of RELAX NG DTD compatibility processors. It is copyrighted by Sun Microsystems.
20 Small part of this test suite relies on the existance of an implementation of XML Schema Part 2. Those test cases are marked by &lt;useXMLSchemaDatatypes/&gt; element in its header.
22 $Id: Compatibility.rng.ssuite,v 1.6 2001/10/11 19:51:41 Bear Exp $
23 </documentation>
25 <testSuite>
26 <title>Annotation feature</title>
27 <documentation>
28 Tests the compatibility with the annotation feature.
29 </documentation>
31 <testSuite>
32 <title>valid test cases</title>
34 <testCase>
35 <correct>
36 <grammar xmlns="&rngURI;">
37 <a:documentation>
38 text annotation at the top of siblings
39 </a:documentation>
40 <start>
41 <element name="dummy">
42 <ref name="body"/>
43 </element>
44 </start>
46 <define name="body">
47 <foo:foo/>
48 <foo:foo>
49 <empty/> <!-- dummy RELAX NG elements -->
50 </foo:foo>
51 <a:documentation>
52 This is OK because there is no preceding RELAX NG elements.
53 </a:documentation>
55 <group>
56 <a:documentation>
57 multiple annotation
58 </a:documentation>
59 <foo:foo/>
60 <a:documentation>
61 multiple annotation for one pattern
62 </a:documentation>
64 <foo:foo>
65 <!-- it should be OK to have annotation inside a foreign element. -->
66 <a:documentation/>
67 </foo:foo>
69 <element>
70 <name>abc</name>
71 <a:documentation>
72 this is OK because it is after the "name" element.
73 </a:documentation>
74 <empty/>
75 </element>
77 <element>
78 <name>abc</name>
79 <a:documentation>
80 multiple annotation
81 </a:documentation>
82 <foo:foo/>
83 <a:documentation>
84 multiple annotation
85 </a:documentation>
86 <empty/>
87 </element>
89 <element name="dummy">
90 <value>123</value>
91 <a:documentation>
92 this is another case where it's OK to have an annotation after something.
93 </a:documentation>
94 </element>
96 <empty>
97 <a:documentation foo:abc="http:xyz" xml:lang="ja">
98 it's OK to have attributes from foreign namespaces
99 </a:documentation>
100 </empty>
101 </group>
102 </define>
103 </grammar>
104 </correct>
105 <!-- there is no test instance to test the validity -->
106 </testCase>
108 </testSuite><!-- end of the valid annotation test suite -->
110 <testSuite>
111 <title>invalid test cases</title>
112 <documentation>
113 Schemas that violates the annotation compatibility.
114 Note that they are actually valid. They are just not compatible with the annotation feature.
115 </documentation>
117 <testSuite>
118 <documentation>
119 these test cases violate the 1st clause
120 "it does not have any child elements".
121 </documentation>
123 <testCase>
124 <correct annotation="incompatible">
125 <grammar xmlns="&rngURI;">
127 <a:documentation>
128 <a:documentation/>
129 </a:documentation>
131 <start>
132 <notAllowed/>
133 </start>
134 </grammar>
135 </correct>
136 </testCase>
138 <testCase>
139 <correct annotation="incompatible">
140 <grammar xmlns="&rngURI;">
142 <a:documentation>
143 <foo:foo/>
144 </a:documentation>
146 <start>
147 <notAllowed/>
148 </start>
149 </grammar>
150 </correct>
151 </testCase>
152 </testSuite>
154 <testSuite>
155 <documentation>
156 these test cases violate the 2nd clause:
157 "it does not have any attribute whose namespace URI is the empty string, the RELAX NG namespace URI or the compatibility annotations namespace URI"
158 </documentation>
160 <testCase>
161 <correct annotation="incompatible">
162 <grammar xmlns="&rngURI;">
164 <a:documentation local="att">
165 text
166 </a:documentation>
168 <start>
169 <notAllowed/>
170 </start>
171 </grammar>
172 </correct>
173 </testCase>
175 <testCase>
176 <correct annotation="incompatible">
177 <grammar xmlns="&rngURI;">
179 <a:documentation a:local="att">
180 text
181 </a:documentation>
183 <start>
184 <notAllowed/>
185 </start>
186 </grammar>
187 </correct>
188 </testCase>
190 <testCase>
191 <correct annotation="incompatible">
192 <grammar xmlns="&rngURI;">
194 <a:documentation rng:href="att">
195 text
196 </a:documentation>
198 <start>
199 <notAllowed/>
200 </start>
201 </grammar>
202 </correct>
203 </testCase>
204 </testSuite>
206 <testSuite>
207 <documentation>
208 these test cases violate the 3rd clause:
209 "if it has a preceding sibling element from the RELAX NG namespace, then the nearest such preceding sibling element is an element that does not allow child elements (i.e. value, param or name)"
210 </documentation>
212 <testCase>
213 <correct annotation="incompatible">
214 <group xmlns="&rngURI;">
216 <notAllowed/>
217 <a:documentation/>
218 </group>
219 </correct>
220 </testCase>
222 <testCase>
223 <correct annotation="incompatible">
224 <group xmlns="&rngURI;">
226 <notAllowed/>
227 <foo:foo/>
228 <a:documentation/>
229 </group>
230 </correct>
231 </testCase>
232 </testSuite>
233 </testSuite> <!-- end of the invalid annotation test suite -->
234 </testSuite> <!-- end of the annotation feature test suite -->
241 <testSuite>
242 <title>ID/IDREF feature</title>
243 <documentation>
244 Tests the compatibility and the soundness with the id/idref feature.
245 </documentation>
247 <testSuite>
248 <title>valid test cases</title>
250 <testCase>
251 <title>very simple use of ID/IDREF</title>
253 <correct>
254 <element name="root" xmlns="&rngURI;">
255 <zeroOrMore datatypeLibrary="&compLibURI;">
256 <element name="item">
257 <optional>
258 <attribute name="id">
259 <data type="ID"/>
260 </attribute>
261 </optional>
262 <optional>
263 <attribute name="idref">
264 <data type="IDREF"/>
265 </attribute>
266 </optional>
267 <optional>
268 <attribute name="idrefs">
269 <data type="IDREFS"/>
270 </attribute>
271 </optional>
272 </element>
273 </zeroOrMore>
274 </element>
275 </correct>
277 <valid ididref="notsound">
278 <root>
279 <item id="abc"/>
280 <item id="abc"/>
281 </root>
282 </valid>
284 <valid>
285 <root>
286 <item idref="abc"/>
287 <item id="abc"/>
288 </root>
289 </valid>
291 <valid>
292 <root>
293 <item idrefs="abc abc abc"/>
294 <item id="abc"/>
295 </root>
296 </valid>
298 <valid ididref="notsound">
299 <root>
300 <item idref="abc"/>
301 </root>
302 </valid>
303 </testCase>
305 <testCase>
306 <title>the same test using XML Schema datatypes</title>
307 <requires datatypeLibrary="&xsdlibURI;"/>
309 <correct>
310 <element name="root" xmlns="&rngURI;">
311 <zeroOrMore datatypeLibrary="&xsdlibURI;">
312 <element name="item">
313 <optional>
314 <attribute name="id">
315 <data type="ID"/>
316 </attribute>
317 </optional>
318 <optional>
319 <attribute name="idref">
320 <data type="IDREF"/>
321 </attribute>
322 </optional>
323 <optional>
324 <attribute name="idrefs">
325 <data type="IDREFS"/>
326 </attribute>
327 </optional>
328 </element>
329 </zeroOrMore>
330 </element>
331 </correct>
333 <valid ididref="notsound">
334 <root>
335 <item id="abc"/>
336 <item id="abc"/>
337 </root>
338 </valid>
340 <valid>
341 <root>
342 <item idref="abc"/>
343 <item id="abc"/>
344 </root>
345 </valid>
347 <valid>
348 <root>
349 <item idrefs="abc abc abc"/>
350 <item id="abc"/>
351 </root>
352 </valid>
354 <valid ididref="notsound">
355 <root>
356 <item idref="abc"/>
357 </root>
358 </valid>
359 </testCase>
361 </testSuite> <!-- end valid test cases -->
364 <testSuite>
365 <title>invalid test cases</title>
366 <documentation>
367 Tests the compatibility violations.
368 </documentation>
370 <testSuite>
371 <title>clause 1 violation</title>
372 <documentation>
373 its parent is an attribute element
374 </documentation>
376 <testCase>
377 <correct ididref="incompatible">
378 <element name="abc" xmlns="&rngURI;">
379 <data type="ID" datatypeLibrary="&compLibURI;"/>
380 </element>
381 </correct>
382 </testCase>
384 <testCase>
385 <correct ididref="incompatible">
386 <grammar xmlns="&rngURI;">
387 <start>
388 <element name="abc">
389 <ref name="foo"/>
390 </element>
391 </start>
393 <define name="foo">
394 <data type="IDREF" datatypeLibrary="&compLibURI;"/>
395 </define>
396 </grammar>
397 </correct>
398 </testCase>
400 <testCase>
401 <title>IDREFS as an element content</title>
402 <correct ididref="incompatible">
403 <element name="abc" xmlns="&rngURI;">
404 <data type="IDREFS" datatypeLibrary="&compLibURI;"/>
405 </element>
406 </correct>
407 </testCase>
408 </testSuite> <!-- end clause 1 violation -->
412 <testSuite>
413 <title>clause 2 violation</title>
414 <documentation>
415 The 2nd clause is "the first child of its attribute parent is a name element"
416 </documentation>
418 <testCase>
419 <correct ididref="incompatible">
420 <element name="abc" xmlns="&rngURI;">
421 <zeroOrMore>
422 <attribute>
423 <anyName/>
424 <data type="ID" datatypeLibrary="&compLibURI;" />
425 </attribute>
426 </zeroOrMore>
427 </element>
428 </correct>
429 </testCase>
431 <testCase>
432 <correct ididref="incompatible">
433 <element name="abc" xmlns="&rngURI;">
434 <attribute>
435 <choice>
436 <name>abc</name>
437 <name>def</name>
438 </choice>
439 <data type="IDREF" datatypeLibrary="&compLibURI;" />
440 </attribute>
441 </element>
442 </correct>
443 </testCase>
445 <testCase>
446 <correct ididref="incompatible">
447 <grammar xmlns="&rngURI;">
448 <start>
449 <element name="abc">
450 <zeroOrMore>
451 <attribute>
452 <nsName ns="http:xyz"/>
453 <ref name="foo"/>
454 </attribute>
455 </zeroOrMore>
456 </element>
457 </start>
459 <define name="foo">
460 <ref name="bar"/>
461 </define>
463 <define name="bar">
464 <data type="IDREFS" datatypeLibrary="&compLibURI;" />
465 </define>
466 </grammar>
467 </correct>
468 </testCase>
469 </testSuite> <!-- end clause 2 violation -->
473 <testSuite>
474 <title>clause 3 violation</title>
475 <documentation>
476 The 3rd clause is "the first child of the element ancestor is a name element"
477 </documentation>
479 <testCase>
480 <correct ididref="incompatible">
481 <element xmlns="&rngURI;">
482 <choice>
483 <name>abc</name>
484 <name>def</name>
485 </choice>
486 <attribute name="goo">
487 <data type="ID" datatypeLibrary="&compLibURI;" />
488 </attribute>
489 </element>
490 </correct>
491 </testCase>
493 <testCase>
494 <correct ididref="incompatible">
495 <grammar xmlns="&rngURI;">
496 <start>
497 <element xmlns="&rngURI;">
498 <anyName/>
499 <ref name="foo"/>
500 </element>
501 </start>
503 <define name="foo">
504 <attribute name="goo">
505 <data type="IDREF" datatypeLibrary="&compLibURI;" />
506 </attribute>
507 </define>
508 </grammar>
509 </correct>
510 </testCase>
512 <testCase>
513 <correct ididref="incompatible">
514 <grammar xmlns="&rngURI;">
515 <start>
516 <element xmlns="&rngURI;">
517 <nsName ns="http:xyz">
518 <except>
519 <name>joe</name>
520 </except>
521 </nsName>
523 <empty/>
524 <ref name="foo"/>
525 </element>
526 </start>
528 <define name="foo">
529 <attribute name="goo">
530 <data type="IDREFS" datatypeLibrary="&compLibURI;" />
531 </attribute>
532 </define>
533 </grammar>
534 </correct>
535 </testCase>
536 </testSuite> <!-- end clause 3 violation -->
542 <testSuite>
543 <title>clause 4 violation</title>
544 <documentation>
545 The 4th clause is "any attribute element that competes with its parent attribute element has an data or value child specifying a datatype associated with the same ID-type"
546 </documentation>
548 <testCase>
549 <correct ididref="incompatible">
550 <!-- foo/@bar is competing -->
551 <element name="root" xmlns="&rngURI;">
552 <element name="foo">
553 <attribute name="bar">
554 <data type="ID" datatypeLibrary="&compLibURI;" />
555 </attribute>
556 </element>
557 <element name="foo">
558 <attribute name="bar">
559 <value>abc</value>
560 </attribute>
561 </element>
562 </element>
563 </correct>
564 </testCase>
567 <testCase>
568 <documentation>
569 This example is ID compatible because after the simplification,
570 the content model of "root" is &lt;notAllowed/&gt;
571 </documentation>
572 <correct>
573 <element name="root" xmlns="&rngURI;">
574 <element name="foo">
575 <attribute name="bar">
576 <data type="ID" datatypeLibrary="&compLibURI;" />
577 </attribute>
578 </element>
579 <notAllowed/> <!-- this effectively kills other two elements -->
580 <element name="foo">
581 <attribute name="bar">
582 <value>abc</value>
583 </attribute>
584 </element>
585 </element>
586 </correct>
587 </testCase>
590 <testCase>
591 <documentation>
592 This example is ID compatible, although it is ambiguous.
593 </documentation>
594 <correct>
595 <choice xmlns="&rngURI;">
596 <element name="foo">
597 <attribute name="bar">
598 <data type="ID" datatypeLibrary="&compLibURI;" />
599 </attribute>
601 <value>123</value>
602 </element>
604 <element name="foo">
605 <attribute name="bar">
606 <data type="ID" datatypeLibrary="&compLibURI;" />
607 </attribute>
609 <value>456</value>
610 </element>
611 </choice>
612 </correct>
613 </testCase>
616 <testCase>
617 <documentation>
618 This example is ID compatible, because one of @bar is
619 unreachable.
620 </documentation>
621 <correct>
622 <grammar xmlns="&rngURI;">
623 <start>
624 <element name="foo">
625 <attribute name="bar">
626 <data type="ID" datatypeLibrary="&compLibURI;" />
627 </attribute>
628 </element>
629 </start>
631 <define name="unused">
632 <element name="foo">
633 <attribute name="bar">
634 <data type="string" datatypeLibrary=""/>
635 </attribute>
636 </element>
637 </define>
638 </grammar>
639 </correct>
640 </testCase>
644 <testCase>
645 <correct ididref="incompatible">
646 <!-- foo/@bar is competing with foo/@* -->
647 <element name="root" xmlns="&rngURI;">
648 <element name="foo">
649 <attribute name="bar">
650 <data type="ID" datatypeLibrary="&compLibURI;" />
651 </attribute>
652 </element>
653 <element name="foo">
654 <zeroOrMore>
655 <attribute>
656 <anyName/>
657 <value>abc</value>
658 </attribute>
659 </zeroOrMore>
660 </element>
661 </element>
662 </correct>
663 </testCase>
667 <testCase>
668 <correct ididref="incompatible">
669 <!-- foo/@bar is competing with */@* -->
670 <element name="root" xmlns="&rngURI;">
671 <element name="foo">
672 <attribute name="bar">
673 <data type="ID" datatypeLibrary="&compLibURI;" />
674 </attribute>
675 </element>
676 <element>
677 <anyName/>
678 <zeroOrMore>
679 <attribute>
680 <anyName/>
681 <value>abc</value>
682 </attribute>
683 </zeroOrMore>
684 </element>
685 </element>
686 </correct>
687 </testCase>
691 <testCase>
692 <correct>
693 <!-- foo/@bar is not competing, although this name class is complex -->
694 <element name="root" xmlns="&rngURI;">
695 <element name="foo">
696 <attribute name="bar">
697 <data type="ID" datatypeLibrary="&compLibURI;" />
698 </attribute>
699 </element>
700 <element>
701 <anyName>
702 <except>
703 <name>foo</name>
704 </except>
705 </anyName>
706 <attribute name="bar">
707 <value>abc</value>
708 </attribute>
709 </element>
710 </element>
711 </correct>
712 </testCase>
713 </testSuite> <!-- end clause 4 violation -->
714 </testSuite> <!-- end invalid test cases -->
715 </testSuite> <!-- end ID/IDREF feature test -->
720 <testSuite>
721 <title>Attribute default values feature</title>
722 <documentation>
723 Tests the compatibility with the
724 attribute default values feature.
725 </documentation>
727 <testSuite>
728 <title>valid test cases</title>
730 <testCase>
731 <correct>
732 <element name="foo" xmlns="&rngURI;">
733 <optional>
734 <attribute name="bar" a:defaultValue="t512">
735 <data type="ID" datatypeLibrary="&compLibURI;"/>
736 </attribute>
737 </optional>
738 </element>
739 </correct>
740 </testCase>
742 <testCase>
743 <correct>
744 <grammar xmlns="&rngURI;">
745 <start>
746 <element name="foo">
747 <ref name="body"/>
748 </element>
749 </start>
751 <define name="body">
752 <!-- after the simplification, this corresponds to
753 <optional><attribute/></optional> -->
754 <interleave>
755 <ref name="empty"/>
756 <group>
757 <ref name="empty"/>
758 <choice>
759 <ref name="empty"/>
760 <attribute name="bar" a:defaultValue="t512">
761 <data type="ID" datatypeLibrary="&compLibURI;"/>
762 </attribute>
763 </choice>
764 <ref name="empty"/>
765 </group>
766 <ref name="empty"/>
767 </interleave>
768 </define>
770 <define name="empty">
771 <choice>
772 <notAllowed/>
773 <oneOrMore>
774 <empty/>
775 </oneOrMore>
776 </choice>
777 </define>
778 </grammar>
779 </correct>
780 </testCase>
781 </testSuite> <!-- end valid test -->
785 <testSuite>
786 <title>clause 1 violation</title>
787 <documentation>
788 The 1st clause is "its first child is a name element"
789 </documentation>
791 <testCase>
792 <correct defaultValue="incompatible">
793 <element name="foo" xmlns="&rngURI;">
794 <zeroOrMore>
795 <attribute a:defaultValue="xyz">
796 <nsName ns=""/>
797 <data type="string"/>
798 </attribute>
799 </zeroOrMore>
800 </element>
801 </correct>
802 </testCase>
804 <testCase>
805 <correct defaultValue="incompatible">
806 <element name="foo" xmlns="&rngURI;">
807 <zeroOrMore>
808 <attribute a:defaultValue="xyz">
809 <anyName/>
810 <data type="string"/>
811 </attribute>
812 </zeroOrMore>
813 </element>
814 </correct>
815 </testCase>
816 </testSuite> <!-- end clause 1 violation -->
820 <testSuite>
821 <title>clause 2 violation</title>
822 <documentation>
823 The 2nd clause is "the first child of the containing element element is a name element"
824 </documentation>
826 <testCase>
827 <correct defaultValue="incompatible">
828 <grammar xmlns="&rngURI;">
829 <start>
830 <element>
831 <choice>
832 <name>abc</name>
833 <name>def</name>
834 </choice>
835 <ref name="att"/>
836 </element>
837 </start>
839 <define name="att">
840 <optional>
841 <attribute name="abc" a:defaultValue="xyz" />
842 </optional>
843 </define>
844 </grammar>
845 </correct>
846 </testCase>
848 <testCase>
849 <correct defaultValue="incompatible">
850 <element xmlns="&rngURI;">
851 <anyName/>
852 <optional>
853 <attribute name="abc" a:defaultValue="xyz" />
854 </optional>
855 </element>
856 </correct>
857 </testCase>
858 </testSuite> <!-- end clause 2 violation -->
862 <testSuite>
863 <title>clause 3 violation</title>
864 <documentation>
865 The 3rd clause is "the value of the a:defaultValue attribute matches the pattern contained in the attribute element"
866 </documentation>
868 <testCase>
869 <correct defaultValue="incompatible">
870 <element name="foo" xmlns="&rngURI;">
871 <optional>
872 <!-- number is an invalid ID value -->
873 <attribute name="bar" a:defaultValue="123 456">
874 <data type="ID" datatypeLibrary="&compLibURI;"/>
875 </attribute>
876 </optional>
877 </element>
878 </correct>
879 </testCase>
881 <testCase>
882 <!--
883 this one is actually compatible because
884 <attribute> will be removed during the simplification.
886 <correct>
887 <grammar xmlns="&rngURI;">
888 <start>
889 <element name="foo">
890 <optional>
891 <attribute name="baz" a:defaultValue="551">
892 <ref name="p1"/>
893 </attribute>
894 </optional>
895 </element>
896 </start>
898 <define name="p1">
899 <ref name="p2"/>
900 </define>
902 <define name="p2">
903 <choice>
904 <data type="ID" datatypeLibrary="&compLibURI;"/>
905 <notAllowed/>
906 </choice>
907 </define>
908 </grammar>
909 </correct>
910 </testCase>
913 <testCase>
914 <correct defaultValue="incompatible">
915 <grammar xmlns="&rngURI;">
916 <start>
917 <element name="foo">
918 <optional>
919 <attribute name="bar" a:defaultValue="246">
920 <ref name="p1"/>
921 </attribute>
922 </optional>
923 </element>
924 </start>
926 <define name="p1">
927 <choice>
928 <group>
929 <data type="ID" datatypeLibrary="&compLibURI;"/>
930 <ref name="notAllowed"/>
931 </group>
932 </choice>
933 </define>
935 <define name="notAllowed">
936 <notAllowed/>
937 </define>
938 </grammar>
939 </correct>
940 </testCase>
942 </testSuite> <!-- end clause 3 violation -->
946 <testSuite>
947 <title>clause 4 violation</title>
948 <documentation>
949 The 4th clause is "the pattern in the attribute element does not contain a data or value element with a context-dependent datatype".
951 This test suite relies on XML Schema datatypes implementation.
952 </documentation>
955 <testCase>
956 <requires datatypeLibrary="&xsdlibURI;"/>
957 <correct defaultValue="incompatible">
958 <element name="foo" xmlns="&rngURI;">
959 <optional>
960 <!-- although "xyz" is always a valid QName value, this is prohibited -->
961 <attribute name="bar" a:defaultValue="xyz">
962 <data type="QName" datatypeLibrary="&xsdlibURI;" />
963 </attribute>
964 </optional>
965 </element>
966 </correct>
967 </testCase>
970 <testCase>
971 <requires datatypeLibrary="&xsdlibURI;"/>
972 <correct defaultValue="incompatible">
973 <element name="foo" xmlns="&rngURI;">
974 <optional>
975 <attribute name="bar" a:defaultValue="abc">
976 <data type="ENTITY" datatypeLibrary="&xsdlibURI;" />
977 </attribute>
978 </optional>
979 </element>
980 </correct>
981 </testCase>
982 </testSuite> <!-- end clause 4 violation -->
986 <testSuite>
987 <title>clause 5 violation</title>
988 <documentation>
989 The 5th clause is "it does not have a oneOrMore ancestor"
990 </documentation>
992 <testCase>
993 <correct defaultValue="incompatible">
994 <element name="foo" xmlns="&rngURI;">
995 <optional>
996 <oneOrMore>
997 <attribute name="bar" a:defaultValue="xyz" />
998 </oneOrMore>
999 </optional>
1000 </element>
1001 </correct>
1002 </testCase>
1004 <testCase>
1005 <correct defaultValue="incompatible">
1006 <element name="foo" xmlns="&rngURI;">
1007 <optional>
1008 <zeroOrMore>
1009 <attribute name="bar" a:defaultValue="xyz" />
1010 </zeroOrMore>
1011 </optional>
1012 </element>
1013 </correct>
1014 </testCase>
1016 <testCase>
1017 <!-- this is compatible because the attribute will be removed during the simplification -->
1018 <correct>
1019 <element name="foo" xmlns="&rngURI;">
1020 <optional>
1021 <zeroOrMore>
1022 <attribute name="bar" a:defaultValue="cnn">
1023 <notAllowed/>
1024 </attribute>
1025 </zeroOrMore>
1026 </optional>
1027 </element>
1028 </correct>
1029 </testCase>
1031 <testCase>
1032 <!-- this is compatible because the attribute will be removed during the simplification -->
1033 <correct>
1034 <element name="foo" xmlns="&rngURI;">
1035 <optional>
1036 <zeroOrMore>
1037 <attribute name="bar" a:defaultValue="bbc" />
1038 </zeroOrMore>
1039 </optional>
1040 <notAllowed/>
1041 </element>
1042 </correct>
1043 </testCase>
1046 <testCase>
1047 <correct>
1048 <element name="foo" xmlns="&rngURI;">
1049 <oneOrMore><!-- this oneOrMore is OK -->
1050 <element name="xyz">
1051 <optional>
1052 <attribute name="bar" a:defaultValue="xyz" />
1053 </optional>
1054 </element>
1055 </oneOrMore>
1056 </element>
1057 </correct>
1058 </testCase>
1059 </testSuite> <!-- end clause 5 violation -->
1063 <testSuite>
1064 <title>clause 6 violation</title>
1065 <documentation>
1066 The 6th clause is "any ancestor that is a choice element has one child that is an empty element"
1067 </documentation>
1069 <testCase>
1070 <correct defaultValue="incompatible">
1071 <grammar xmlns="&rngURI;">
1072 <start>
1073 <element name="root">
1074 <!-- choice with non-empty child -->
1075 <choice>
1076 <element name="child">
1077 <empty/>
1078 </element>
1079 <optional>
1080 <attribute name="abc" a:defaultValue="abc"/>
1081 </optional>
1082 </choice>
1083 </element>
1084 </start>
1085 </grammar>
1086 </correct>
1087 </testCase>
1089 <testCase>
1090 <correct defaultValue="incompatible">
1091 <grammar xmlns="&rngURI;">
1092 <start>
1093 <element name="root">
1094 <!-- a choice with an element child. This is no good. -->
1095 <choice>
1096 <empty/>
1097 <element name="child">
1098 <empty/>
1099 </element>
1100 <attribute name="abc" a:defaultValue="abc"/>
1101 </choice>
1102 </element>
1103 </start>
1104 </grammar>
1105 </correct>
1106 </testCase>
1109 <testCase>
1110 <correct>
1111 <grammar xmlns="&rngURI;">
1112 <start>
1113 <element name="root">
1114 <!-- one of the branch is empty. So this is OK -->
1115 <choice>
1116 <ref name="empty"/>
1117 <attribute name="abc" a:defaultValue="abc"/>
1118 </choice>
1119 </element>
1120 </start>
1122 <define name="empty">
1123 <choice>
1124 <notAllowed/>
1125 <group>
1126 <oneOrMore>
1127 <empty/>
1128 </oneOrMore>
1129 </group>
1130 <notAllowed/>
1131 </choice>
1132 </define>
1133 </grammar>
1134 </correct>
1135 </testCase>
1138 <testCase>
1139 <correct>
1140 <grammar xmlns="&rngURI;">
1141 <start>
1142 <element name="root">
1143 <!-- it is OK to have sequence -->
1144 <optional>
1145 <attribute name="abc" a:defaultValue="abc"/>
1146 <attribute name="def" a:defaultValue="abc"/>
1147 </optional>
1148 </element>
1149 </start>
1150 </grammar>
1151 </correct>
1152 </testCase>
1153 </testSuite> <!-- end clause 6 violation -->
1157 <testSuite>
1158 <title>clause 7 violation</title>
1159 <documentation>
1160 The 7th clause is "it has at least one choice ancestor"
1161 </documentation>
1163 <testCase>
1164 <correct defaultValue="incompatible">
1165 <grammar xmlns="&rngURI;">
1166 <start>
1167 <element name="root">
1168 <attribute name="abc" a:defaultValue="abc"/>
1169 </element>
1170 </start>
1171 </grammar>
1172 </correct>
1173 </testCase>
1175 <testCase>
1176 <correct defaultValue="incompatible">
1177 <grammar xmlns="&rngURI;">
1178 <start>
1179 <element name="root">
1180 <choice>
1181 <attribute name="abc" a:defaultValue="abc"/>
1182 <ref name="notAllowed"/>
1183 </choice>
1184 </element>
1185 </start>
1187 <define name="notAllowed">
1188 <interleave>
1189 <empty/>
1190 <mixed>
1191 <list>
1192 <group>
1193 <empty/>
1194 <zeroOrMore>
1195 <notAllowed/>
1196 </zeroOrMore>
1197 </group>
1198 </list>
1199 </mixed>
1200 </interleave>
1201 </define>
1202 </grammar>
1203 </correct>
1204 </testCase>
1205 </testSuite> <!-- end clause 6 violation -->
1213 <testSuite>
1214 <title>clause 8 violation</title>
1215 <documentation>
1216 The 8th clause is about competing attributes.
1217 </documentation>
1219 <testCase>
1220 <correct defaultValue="incompatible">
1221 <grammar xmlns="&rngURI;">
1222 <start>
1223 <element name="root">
1224 <optional>
1225 <attribute name="abc" a:defaultValue="abc"/>
1226 </optional>
1227 <optional>
1228 <element name="root"><!-- competing element -->
1229 <empty/><!-- without attribute value -->
1230 </element>
1231 </optional>
1232 </element>
1233 </start>
1234 </grammar>
1235 </correct>
1236 </testCase>
1238 <testCase>
1239 <correct defaultValue="incompatible">
1240 <grammar xmlns="&rngURI;">
1241 <start>
1242 <element name="root">
1243 <optional>
1244 <attribute name="abc" a:defaultValue="abc"/>
1245 </optional>
1246 <optional>
1247 <element name="root"><!-- competing element -->
1248 <optional><!-- with a different default value -->
1249 <attribute name="abc" a:defaultValue="xyz"/>
1250 </optional>
1251 </element>
1252 </optional>
1253 </element>
1254 </start>
1255 </grammar>
1256 </correct>
1257 </testCase>
1259 <testCase>
1260 <requires datatypeLibrary="&xsdlibURI;"/>
1261 <correct defaultValue="incompatible">
1262 <grammar xmlns="&rngURI;" datatypeLibrary="&xsdlibURI;">
1263 <start>
1264 <element name="root">
1265 <optional>
1266 <attribute name="abc" a:defaultValue="5">
1267 <data type="integer"/>
1268 </attribute>
1269 </optional>
1270 <optional>
1271 <element name="root"><!-- competing element -->
1272 <optional>
1273 <attribute name="abc" a:defaultValue="+5">
1274 <!-- +5 and 5 are actually the same value in the value space, but the comparision must be done at the lexical level. -->
1275 <data type="integer"/>
1276 </attribute>
1277 </optional>
1278 </element>
1279 </optional>
1280 </element>
1281 </start>
1282 </grammar>
1283 </correct>
1284 </testCase>
1286 <testCase>
1287 <correct defaultValue="incompatible">
1288 <grammar xmlns="&rngURI;">
1289 <start>
1290 <element name="root">
1291 <optional>
1292 <attribute name="abc" a:defaultValue="abc"/>
1293 </optional>
1294 <optional>
1295 <element><!-- competing element -->
1296 <anyName/>
1297 <empty/>
1298 </element>
1299 </optional>
1300 </element>
1301 </start>
1302 </grammar>
1303 </correct>
1304 </testCase>
1306 <testCase>
1307 <correct>
1308 <grammar xmlns="&rngURI;">
1309 <start>
1310 <element name="root">
1311 <optional>
1312 <attribute name="abc" a:defaultValue="abc"/>
1313 </optional>
1314 </element>
1315 </start>
1317 <define name="unreferenced">
1318 <element name="root">
1319 <!-- this is not competing, because this pattern will be removed during the simplification -->
1320 <empty/>
1321 </element>
1322 </define>
1323 </grammar>
1324 </correct>
1325 </testCase>
1328 <testCase>
1329 <requires datatypeLibrary="&xsdlibURI;"/>
1330 <correct>
1331 <grammar xmlns="&rngURI;">
1332 <start>
1333 <element name="root">
1334 <optional>
1335 <attribute name="abc" a:defaultValue="3"/>
1336 </optional>
1337 <!-- these two have the same default value. So it's OK -->
1338 <element name="root">
1339 <optional>
1340 <attribute name="abc" a:defaultValue="3">
1341 <data type="integer" datatypeLibrary="&xsdlibURI;"/>
1342 </attribute>
1343 </optional>
1344 </element>
1345 </element>
1346 </start>
1347 </grammar>
1348 </correct>
1349 </testCase>
1351 </testSuite> <!-- end clause 7 violation -->
1352 </testSuite> <!-- end def att value feature test -->
1354 </testSuite>