File: union_test_inline.yml

package info (click to toggle)
libxml-validator-schema-perl 1.10-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 708 kB
  • sloc: perl: 3,682; xml: 16; makefile: 2
file content (78 lines) | stat: -rw-r--r-- 2,089 bytes parent folder | download | duplicates (3)
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
# Test correct behaviour on unions with a good schema
# This defines a union using inline simpleTypes.  This syntax isn't
# described in http://www.w3schools.com/schema/el_union.asp but it is
# presumably contained somewhere in the formal definitions and is
# recognised by other validators. In any case we've been using this format
# extensively for some time.

--- |
<?xml version="1.0" encoding='ISO-8859-1'?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:documentation>
      #########################################################################
      Union test
      #########################################################################
    </xs:documentation>
  </xs:annotation>
  
   
  
  <xs:element name="Message-Text">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:minLength value="0"/>
        <xs:maxLength value="200"/>
      </xs:restriction>    
    </xs:simpleType>
  </xs:element>
  
    

  <xs:element name="decimal-or-tba">
    <xs:simpleType>
      <xs:union>
        <xs:simpleType>
          <xs:restriction base="xs:decimal">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="999999"/>
          </xs:restriction>
        </xs:simpleType>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="TBA"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:union>
    </xs:simpleType>
  </xs:element>      

 
  <xs:element name="my-root">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Message-Text" minOccurs="1" maxOccurs="1"/>
        <xs:element ref="decimal-or-tba" minOccurs="1" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
         
</xs:schema>

--- |
<my-root>
   <Message-Text>union test pass</Message-Text>
   <decimal-or-tba>99999</decimal-or-tba>
   <decimal-or-tba>TBA</decimal-or-tba>
</my-root>
--- >
PASS

--- |
<my-root>
   <Message-Text>union test fail 1</Message-Text>
   <decimal-or-tba>xyz</decimal-or-tba>
</my-root>
--- >
FAIL