File: xml-prolog-accepted-versions.html

package info (click to toggle)
firefox 147.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,484 kB
  • sloc: cpp: 7,607,246; javascript: 6,533,185; ansic: 3,775,227; python: 1,415,393; xml: 634,561; asm: 438,951; java: 186,241; sh: 62,752; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (97 lines) | stat: -rw-r--r-- 2,955 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<meta charset="utf-8">
<title>Accepted versions in XML prolog</title>
<link rel="help" href="https://www.w3.org/TR/REC-xml/#sec-prolog-dtd">
<meta name="assert" content="VersionNum production accepts any 1.x version">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
  'use strict';

  function string_to_xml_document(s) {
    let parser = new DOMParser();
    return parser.parseFromString(s, 'text/xml');

  }

  test(function() {
    assert_equals(string_to_xml_document(
                    `<?xml version="1.0"?>
                     <a></a>`
                  ).documentElement.tagName,
                  "a");
  }, "XML 1.0 is accepted");

  test(function() {
    assert_equals(string_to_xml_document(
                    `<?xml version="1.1"?>
                     <b></b>`
                  ).documentElement.tagName,
                  "b");
  }, "XML 1.1 is accepted");

  test(function() {
    assert_equals(string_to_xml_document(
                    `<?xml version="1.2"?>
                     <c></c>`
                  ).documentElement.tagName,
                  "c");
  }, "XML 1.2 is accepted");

  test(function() {
    assert_equals(string_to_xml_document(
                    `<?xml version="1.7"?>
                     <d></d>`
                  ).documentElement.tagName,
                  "d");
  }, "XML 1.7 is accepted");

  test(function() {
    assert_equals(string_to_xml_document(
                    `<?xml version="1.1075"?>
                     <e></e>`
                  ).documentElement.tagName,
                  "e");
  }, "XML 1.1075 is accepted");

  test(function() {
    assert_equals(string_to_xml_document(
                    `<?xml version="1.000"?>
                     <f></f>`
                  ).documentElement.tagName,
                  "f");
  }, "XML 1.000 is accepted");

  test(function() {
    assert_not_equals(string_to_xml_document(
                        `<?xml version="10.0"?>
                         <x></x>`
                      ).documentElement.tagName,
                      "x");
  }, "XML 10.0 is NOT accepted");

  test(function() {
    assert_not_equals(string_to_xml_document(
                        `<?xml version="100"?>
                         <x></x>`
                      ).documentElement.tagName,
                      "x");
  }, "XML 100 is NOT accepted");

  test(function() {
    assert_not_equals(string_to_xml_document(
                        `<?xml version="2.0"?>
                         <x></x>`
                      ).documentElement.tagName,
                      "x");
  }, "XML 2.0 is NOT accepted");

  test(function() {
    assert_not_equals(string_to_xml_document(
                        `<?xml version="17.0"?>
                         <x></x>`
                      ).documentElement.tagName,
                      "x");
  }, "XML 17.0 is NOT accepted");

</script>