xml-prolog-accepted-versions.html (2955B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Accepted versions in XML prolog</title> 4 <link rel="help" href="https://www.w3.org/TR/REC-xml/#sec-prolog-dtd"> 5 <meta name="assert" content="VersionNum production accepts any 1.x version"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script> 9 'use strict'; 10 11 function string_to_xml_document(s) { 12 let parser = new DOMParser(); 13 return parser.parseFromString(s, 'text/xml'); 14 15 } 16 17 test(function() { 18 assert_equals(string_to_xml_document( 19 `<?xml version="1.0"?> 20 <a></a>` 21 ).documentElement.tagName, 22 "a"); 23 }, "XML 1.0 is accepted"); 24 25 test(function() { 26 assert_equals(string_to_xml_document( 27 `<?xml version="1.1"?> 28 <b></b>` 29 ).documentElement.tagName, 30 "b"); 31 }, "XML 1.1 is accepted"); 32 33 test(function() { 34 assert_equals(string_to_xml_document( 35 `<?xml version="1.2"?> 36 <c></c>` 37 ).documentElement.tagName, 38 "c"); 39 }, "XML 1.2 is accepted"); 40 41 test(function() { 42 assert_equals(string_to_xml_document( 43 `<?xml version="1.7"?> 44 <d></d>` 45 ).documentElement.tagName, 46 "d"); 47 }, "XML 1.7 is accepted"); 48 49 test(function() { 50 assert_equals(string_to_xml_document( 51 `<?xml version="1.1075"?> 52 <e></e>` 53 ).documentElement.tagName, 54 "e"); 55 }, "XML 1.1075 is accepted"); 56 57 test(function() { 58 assert_equals(string_to_xml_document( 59 `<?xml version="1.000"?> 60 <f></f>` 61 ).documentElement.tagName, 62 "f"); 63 }, "XML 1.000 is accepted"); 64 65 test(function() { 66 assert_not_equals(string_to_xml_document( 67 `<?xml version="10.0"?> 68 <x></x>` 69 ).documentElement.tagName, 70 "x"); 71 }, "XML 10.0 is NOT accepted"); 72 73 test(function() { 74 assert_not_equals(string_to_xml_document( 75 `<?xml version="100"?> 76 <x></x>` 77 ).documentElement.tagName, 78 "x"); 79 }, "XML 100 is NOT accepted"); 80 81 test(function() { 82 assert_not_equals(string_to_xml_document( 83 `<?xml version="2.0"?> 84 <x></x>` 85 ).documentElement.tagName, 86 "x"); 87 }, "XML 2.0 is NOT accepted"); 88 89 test(function() { 90 assert_not_equals(string_to_xml_document( 91 `<?xml version="17.0"?> 92 <x></x>` 93 ).documentElement.tagName, 94 "x"); 95 }, "XML 17.0 is NOT accepted"); 96 97 </script>