1 <?xml version=
"1.0" encoding=
"UTF-8" standalone=
"yes" ?>
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">
9 xmlns:
a=
"http://relaxng.org/ns/compatibility/annotations/1.0"
14 <title>RELAX NG DTD Compatibility Test Suite
</title>
15 <author>Sun Microsystems
</author>
16 <email>kohsuke.kawaguchi@sun.com
</email>
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
<useXMLSchemaDatatypes/
> element in its header.
22 $Id: Compatibility.rng.ssuite,v
1.6 2001/
10/
11 19:
51:
41 Bear Exp $
26 <title>Annotation feature
</title>
28 Tests the compatibility with the annotation feature.
32 <title>valid test cases
</title>
36 <grammar xmlns=
"&rngURI;">
38 text annotation at the top of siblings
41 <element name=
"dummy">
49 <empty/> <!-- dummy RELAX NG elements -->
52 This is OK because there is no preceding RELAX NG elements.
61 multiple annotation for one pattern
65 <!-- it should be OK to have annotation inside a foreign element. -->
72 this is OK because it is after the
"name" element.
89 <element name=
"dummy">
92 this is another case where it's OK to have an annotation after something.
97 <a:documentation foo:
abc=
"http:xyz" xml:
lang=
"ja">
98 it's OK to have attributes from foreign namespaces
105 <!-- there is no test instance to test the validity -->
108 </testSuite><!-- end of the valid annotation test suite -->
111 <title>invalid test cases
</title>
113 Schemas that violates the annotation compatibility.
114 Note that they are actually valid. They are just not compatible with the annotation feature.
119 these test cases violate the
1st clause
120 "it does not have any child elements".
124 <correct annotation=
"incompatible">
125 <grammar xmlns=
"&rngURI;">
139 <correct annotation=
"incompatible">
140 <grammar xmlns=
"&rngURI;">
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"
161 <correct annotation=
"incompatible">
162 <grammar xmlns=
"&rngURI;">
164 <a:documentation local=
"att">
176 <correct annotation=
"incompatible">
177 <grammar xmlns=
"&rngURI;">
179 <a:documentation a:
local=
"att">
191 <correct annotation=
"incompatible">
192 <grammar xmlns=
"&rngURI;">
194 <a:documentation rng:
href=
"att">
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)"
213 <correct annotation=
"incompatible">
214 <group xmlns=
"&rngURI;">
223 <correct annotation=
"incompatible">
224 <group xmlns=
"&rngURI;">
233 </testSuite> <!-- end of the invalid annotation test suite -->
234 </testSuite> <!-- end of the annotation feature test suite -->
242 <title>ID/IDREF feature
</title>
244 Tests the compatibility and the soundness with the id/idref feature.
248 <title>valid test cases
</title>
251 <title>very simple use of ID/IDREF
</title>
254 <element name=
"root" xmlns=
"&rngURI;">
255 <zeroOrMore datatypeLibrary=
"&compLibURI;">
256 <element name=
"item">
258 <attribute name=
"id">
263 <attribute name=
"idref">
268 <attribute name=
"idrefs">
269 <data type=
"IDREFS"/>
277 <valid ididref=
"notsound">
293 <item idrefs=
"abc abc abc"/>
298 <valid ididref=
"notsound">
306 <title>the same test using XML Schema datatypes
</title>
307 <requires datatypeLibrary=
"&xsdlibURI;"/>
310 <element name=
"root" xmlns=
"&rngURI;">
311 <zeroOrMore datatypeLibrary=
"&xsdlibURI;">
312 <element name=
"item">
314 <attribute name=
"id">
319 <attribute name=
"idref">
324 <attribute name=
"idrefs">
325 <data type=
"IDREFS"/>
333 <valid ididref=
"notsound">
349 <item idrefs=
"abc abc abc"/>
354 <valid ididref=
"notsound">
361 </testSuite> <!-- end valid test cases -->
365 <title>invalid test cases
</title>
367 Tests the compatibility violations.
371 <title>clause
1 violation
</title>
373 its parent is an attribute element
377 <correct ididref=
"incompatible">
378 <element name=
"abc" xmlns=
"&rngURI;">
379 <data type=
"ID" datatypeLibrary=
"&compLibURI;"/>
385 <correct ididref=
"incompatible">
386 <grammar xmlns=
"&rngURI;">
394 <data type=
"IDREF" datatypeLibrary=
"&compLibURI;"/>
401 <title>IDREFS as an element content
</title>
402 <correct ididref=
"incompatible">
403 <element name=
"abc" xmlns=
"&rngURI;">
404 <data type=
"IDREFS" datatypeLibrary=
"&compLibURI;"/>
408 </testSuite> <!-- end clause 1 violation -->
413 <title>clause
2 violation
</title>
415 The
2nd clause is
"the first child of its attribute parent is a name element"
419 <correct ididref=
"incompatible">
420 <element name=
"abc" xmlns=
"&rngURI;">
424 <data type=
"ID" datatypeLibrary=
"&compLibURI;" />
432 <correct ididref=
"incompatible">
433 <element name=
"abc" xmlns=
"&rngURI;">
439 <data type=
"IDREF" datatypeLibrary=
"&compLibURI;" />
446 <correct ididref=
"incompatible">
447 <grammar xmlns=
"&rngURI;">
452 <nsName ns=
"http:xyz"/>
464 <data type=
"IDREFS" datatypeLibrary=
"&compLibURI;" />
469 </testSuite> <!-- end clause 2 violation -->
474 <title>clause
3 violation
</title>
476 The
3rd clause is
"the first child of the element ancestor is a name element"
480 <correct ididref=
"incompatible">
481 <element xmlns=
"&rngURI;">
486 <attribute name=
"goo">
487 <data type=
"ID" datatypeLibrary=
"&compLibURI;" />
494 <correct ididref=
"incompatible">
495 <grammar xmlns=
"&rngURI;">
497 <element xmlns=
"&rngURI;">
504 <attribute name=
"goo">
505 <data type=
"IDREF" datatypeLibrary=
"&compLibURI;" />
513 <correct ididref=
"incompatible">
514 <grammar xmlns=
"&rngURI;">
516 <element xmlns=
"&rngURI;">
517 <nsName ns=
"http:xyz">
529 <attribute name=
"goo">
530 <data type=
"IDREFS" datatypeLibrary=
"&compLibURI;" />
536 </testSuite> <!-- end clause 3 violation -->
543 <title>clause
4 violation
</title>
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"
549 <correct ididref=
"incompatible">
550 <!-- foo/@bar is competing -->
551 <element name=
"root" xmlns=
"&rngURI;">
553 <attribute name=
"bar">
554 <data type=
"ID" datatypeLibrary=
"&compLibURI;" />
558 <attribute name=
"bar">
569 This example is ID compatible because after the simplification,
570 the content model of
"root" is
<notAllowed/
>
573 <element name=
"root" xmlns=
"&rngURI;">
575 <attribute name=
"bar">
576 <data type=
"ID" datatypeLibrary=
"&compLibURI;" />
579 <notAllowed/> <!-- this effectively kills other two elements -->
581 <attribute name=
"bar">
592 This example is ID compatible, although it is ambiguous.
595 <choice xmlns=
"&rngURI;">
597 <attribute name=
"bar">
598 <data type=
"ID" datatypeLibrary=
"&compLibURI;" />
605 <attribute name=
"bar">
606 <data type=
"ID" datatypeLibrary=
"&compLibURI;" />
618 This example is ID compatible, because one of @bar is
622 <grammar xmlns=
"&rngURI;">
625 <attribute name=
"bar">
626 <data type=
"ID" datatypeLibrary=
"&compLibURI;" />
631 <define name=
"unused">
633 <attribute name=
"bar">
634 <data type=
"string" datatypeLibrary=
""/>
645 <correct ididref=
"incompatible">
646 <!-- foo/@bar is competing with foo/@* -->
647 <element name=
"root" xmlns=
"&rngURI;">
649 <attribute name=
"bar">
650 <data type=
"ID" datatypeLibrary=
"&compLibURI;" />
668 <correct ididref=
"incompatible">
669 <!-- foo/@bar is competing with */@* -->
670 <element name=
"root" xmlns=
"&rngURI;">
672 <attribute name=
"bar">
673 <data type=
"ID" datatypeLibrary=
"&compLibURI;" />
693 <!-- foo/@bar is not competing, although this name class is complex -->
694 <element name=
"root" xmlns=
"&rngURI;">
696 <attribute name=
"bar">
697 <data type=
"ID" datatypeLibrary=
"&compLibURI;" />
706 <attribute name=
"bar">
713 </testSuite> <!-- end clause 4 violation -->
714 </testSuite> <!-- end invalid test cases -->
715 </testSuite> <!-- end ID/IDREF feature test -->
721 <title>Attribute default values feature
</title>
723 Tests the compatibility with the
724 attribute default values feature.
728 <title>valid test cases
</title>
732 <element name=
"foo" xmlns=
"&rngURI;">
734 <attribute name=
"bar" a:
defaultValue=
"t512">
735 <data type=
"ID" datatypeLibrary=
"&compLibURI;"/>
744 <grammar xmlns=
"&rngURI;">
752 <!-- after the simplification, this corresponds to
753 <optional><attribute/></optional> -->
760 <attribute name=
"bar" a:
defaultValue=
"t512">
761 <data type=
"ID" datatypeLibrary=
"&compLibURI;"/>
770 <define name=
"empty">
781 </testSuite> <!-- end valid test -->
786 <title>clause
1 violation
</title>
788 The
1st clause is
"its first child is a name element"
792 <correct defaultValue=
"incompatible">
793 <element name=
"foo" xmlns=
"&rngURI;">
795 <attribute a:
defaultValue=
"xyz">
797 <data type=
"string"/>
805 <correct defaultValue=
"incompatible">
806 <element name=
"foo" xmlns=
"&rngURI;">
808 <attribute a:
defaultValue=
"xyz">
810 <data type=
"string"/>
816 </testSuite> <!-- end clause 1 violation -->
821 <title>clause
2 violation
</title>
823 The
2nd clause is
"the first child of the containing element element is a name element"
827 <correct defaultValue=
"incompatible">
828 <grammar xmlns=
"&rngURI;">
841 <attribute name=
"abc" a:
defaultValue=
"xyz" />
849 <correct defaultValue=
"incompatible">
850 <element xmlns=
"&rngURI;">
853 <attribute name=
"abc" a:
defaultValue=
"xyz" />
858 </testSuite> <!-- end clause 2 violation -->
863 <title>clause
3 violation
</title>
865 The
3rd clause is
"the value of the a:defaultValue attribute matches the pattern contained in the attribute element"
869 <correct defaultValue=
"incompatible">
870 <element name=
"foo" xmlns=
"&rngURI;">
872 <!-- number is an invalid ID value -->
873 <attribute name=
"bar" a:
defaultValue=
"123 456">
874 <data type=
"ID" datatypeLibrary=
"&compLibURI;"/>
883 this one is actually compatible because
884 <attribute> will be removed during the simplification.
887 <grammar xmlns=
"&rngURI;">
891 <attribute name=
"baz" a:
defaultValue=
"551">
904 <data type=
"ID" datatypeLibrary=
"&compLibURI;"/>
914 <correct defaultValue=
"incompatible">
915 <grammar xmlns=
"&rngURI;">
919 <attribute name=
"bar" a:
defaultValue=
"246">
929 <data type=
"ID" datatypeLibrary=
"&compLibURI;"/>
930 <ref name=
"notAllowed"/>
935 <define name=
"notAllowed">
942 </testSuite> <!-- end clause 3 violation -->
947 <title>clause
4 violation
</title>
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.
956 <requires datatypeLibrary=
"&xsdlibURI;"/>
957 <correct defaultValue=
"incompatible">
958 <element name=
"foo" xmlns=
"&rngURI;">
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;" />
971 <requires datatypeLibrary=
"&xsdlibURI;"/>
972 <correct defaultValue=
"incompatible">
973 <element name=
"foo" xmlns=
"&rngURI;">
975 <attribute name=
"bar" a:
defaultValue=
"abc">
976 <data type=
"ENTITY" datatypeLibrary=
"&xsdlibURI;" />
982 </testSuite> <!-- end clause 4 violation -->
987 <title>clause
5 violation
</title>
989 The
5th clause is
"it does not have a oneOrMore ancestor"
993 <correct defaultValue=
"incompatible">
994 <element name=
"foo" xmlns=
"&rngURI;">
997 <attribute name=
"bar" a:
defaultValue=
"xyz" />
1005 <correct defaultValue=
"incompatible">
1006 <element name=
"foo" xmlns=
"&rngURI;">
1009 <attribute name=
"bar" a:
defaultValue=
"xyz" />
1017 <!-- this is compatible because the attribute will be removed during the simplification -->
1019 <element name=
"foo" xmlns=
"&rngURI;">
1022 <attribute name=
"bar" a:
defaultValue=
"cnn">
1032 <!-- this is compatible because the attribute will be removed during the simplification -->
1034 <element name=
"foo" xmlns=
"&rngURI;">
1037 <attribute name=
"bar" a:
defaultValue=
"bbc" />
1048 <element name=
"foo" xmlns=
"&rngURI;">
1049 <oneOrMore><!-- this oneOrMore is OK -->
1050 <element name=
"xyz">
1052 <attribute name=
"bar" a:
defaultValue=
"xyz" />
1059 </testSuite> <!-- end clause 5 violation -->
1064 <title>clause
6 violation
</title>
1066 The
6th clause is
"any ancestor that is a choice element has one child that is an empty element"
1070 <correct defaultValue=
"incompatible">
1071 <grammar xmlns=
"&rngURI;">
1073 <element name=
"root">
1074 <!-- choice with non-empty child -->
1076 <element name=
"child">
1080 <attribute name=
"abc" a:
defaultValue=
"abc"/>
1090 <correct defaultValue=
"incompatible">
1091 <grammar xmlns=
"&rngURI;">
1093 <element name=
"root">
1094 <!-- a choice with an element child. This is no good. -->
1097 <element name=
"child">
1100 <attribute name=
"abc" a:
defaultValue=
"abc"/>
1111 <grammar xmlns=
"&rngURI;">
1113 <element name=
"root">
1114 <!-- one of the branch is empty. So this is OK -->
1117 <attribute name=
"abc" a:
defaultValue=
"abc"/>
1122 <define name=
"empty">
1140 <grammar xmlns=
"&rngURI;">
1142 <element name=
"root">
1143 <!-- it is OK to have sequence -->
1145 <attribute name=
"abc" a:
defaultValue=
"abc"/>
1146 <attribute name=
"def" a:
defaultValue=
"abc"/>
1153 </testSuite> <!-- end clause 6 violation -->
1158 <title>clause
7 violation
</title>
1160 The
7th clause is
"it has at least one choice ancestor"
1164 <correct defaultValue=
"incompatible">
1165 <grammar xmlns=
"&rngURI;">
1167 <element name=
"root">
1168 <attribute name=
"abc" a:
defaultValue=
"abc"/>
1176 <correct defaultValue=
"incompatible">
1177 <grammar xmlns=
"&rngURI;">
1179 <element name=
"root">
1181 <attribute name=
"abc" a:
defaultValue=
"abc"/>
1182 <ref name=
"notAllowed"/>
1187 <define name=
"notAllowed">
1205 </testSuite> <!-- end clause 6 violation -->
1214 <title>clause
8 violation
</title>
1216 The
8th clause is about competing attributes.
1220 <correct defaultValue=
"incompatible">
1221 <grammar xmlns=
"&rngURI;">
1223 <element name=
"root">
1225 <attribute name=
"abc" a:
defaultValue=
"abc"/>
1228 <element name=
"root"><!-- competing element -->
1229 <empty/><!-- without attribute value -->
1239 <correct defaultValue=
"incompatible">
1240 <grammar xmlns=
"&rngURI;">
1242 <element name=
"root">
1244 <attribute name=
"abc" a:
defaultValue=
"abc"/>
1247 <element name=
"root"><!-- competing element -->
1248 <optional><!-- with a different default value -->
1249 <attribute name=
"abc" a:
defaultValue=
"xyz"/>
1260 <requires datatypeLibrary=
"&xsdlibURI;"/>
1261 <correct defaultValue=
"incompatible">
1262 <grammar xmlns=
"&rngURI;" datatypeLibrary=
"&xsdlibURI;">
1264 <element name=
"root">
1266 <attribute name=
"abc" a:
defaultValue=
"5">
1267 <data type=
"integer"/>
1271 <element name=
"root"><!-- competing element -->
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"/>
1287 <correct defaultValue=
"incompatible">
1288 <grammar xmlns=
"&rngURI;">
1290 <element name=
"root">
1292 <attribute name=
"abc" a:
defaultValue=
"abc"/>
1295 <element><!-- competing element -->
1308 <grammar xmlns=
"&rngURI;">
1310 <element name=
"root">
1312 <attribute name=
"abc" a:
defaultValue=
"abc"/>
1317 <define name=
"unreferenced">
1318 <element name=
"root">
1319 <!-- this is not competing, because this pattern will be removed during the simplification -->
1329 <requires datatypeLibrary=
"&xsdlibURI;"/>
1331 <grammar xmlns=
"&rngURI;">
1333 <element name=
"root">
1335 <attribute name=
"abc" a:
defaultValue=
"3"/>
1337 <!-- these two have the same default value. So it's OK -->
1338 <element name=
"root">
1340 <attribute name=
"abc" a:
defaultValue=
"3">
1341 <data type=
"integer" datatypeLibrary=
"&xsdlibURI;"/>
1351 </testSuite> <!-- end clause 7 violation -->
1352 </testSuite> <!-- end def att value feature test -->