1#
2# Copyright (c), 2016-2020, SISSA (International School for Advanced Studies).
3# All rights reserved.
4# This file is distributed under the terms of the MIT License.
5# See the file 'LICENSE' in the root directory of the present
6# distribution, or http://opensource.org/licenses/MIT.
7#
8# @author Davide Brunato <brunato@sissa.it>
9#
10"""
11This module contains namespace definitions for W3C core standards.
12"""
13import os
14
15###
16# Namespace URIs for schemas
17XSD_NAMESPACE = 'http://www.w3.org/2001/XMLSchema'
18"URI of the XML Schema Definition namespace (xs|xsd)"
19
20XSI_NAMESPACE = 'http://www.w3.org/2001/XMLSchema-instance'
21"URI of the XML Schema Instance namespace (xsi)"
22
23XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'
24"URI of the XML namespace (xml)"
25
26XHTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'
27XHTML_DATATYPES_NAMESPACE = 'http://www.w3.org/1999/xhtml/datatypes/'
28"URIs of the Extensible Hypertext Markup Language namespace (html)"
29
30XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink'
31"URI of the XML Linking Language (XLink)"
32
33XSLT_NAMESPACE = "http://www.w3.org/1999/XSL/Transform"
34"URI of the XSL Transformations namespace (xslt)"
35
36HFP_NAMESPACE = 'http://www.w3.org/2001/XMLSchema-hasFacetAndProperty'
37"URI of the XML Schema has Facet and Property namespace (hfp)"
38
39VC_NAMESPACE = 'http://www.w3.org/2007/XMLSchema-versioning'
40"URI of the XML Schema Versioning namespace (vc)"
41
42###
43# Namespace URIs for XML documents
44WSDL_NAMESPACE = 'http://schemas.xmlsoap.org/wsdl/'
45SOAP_NAMESPACE = 'http://schemas.xmlsoap.org/wsdl/soap/'
46SOAP_ENVELOPE_NAMESPACE = 'http://schemas.xmlsoap.org/soap/envelope/'
47SOAP_ENCODING_NAMESPACE = 'http://schemas.xmlsoap.org/soap/encoding/'
48
49
50###
51# Schema location hints
52
53SCHEMAS_DIR = os.path.join(os.path.dirname(__file__), 'schemas/')
54
55LOCATION_HINTS = {
56    # Locally saved schemas
57    # HFP_NAMESPACE: os.path.join(SCHEMAS_DIR, 'HFP/XMLSchema-hasFacetAndProperty_minimal.xsd'),
58    VC_NAMESPACE: os.path.join(SCHEMAS_DIR, 'XSI/XMLSchema-versioning.xsd'),
59    XLINK_NAMESPACE: os.path.join(SCHEMAS_DIR, 'XLINK/xlink.xsd'),
60    XHTML_NAMESPACE: os.path.join(SCHEMAS_DIR, 'XHTML/xhtml1-strict.xsd'),
61    WSDL_NAMESPACE: os.path.join(SCHEMAS_DIR, 'WSDL/wsdl.xsd'),
62    SOAP_NAMESPACE: os.path.join(SCHEMAS_DIR, 'WSDL/wsdl-soap.xsd'),
63    SOAP_ENVELOPE_NAMESPACE: os.path.join(SCHEMAS_DIR, 'WSDL/soap-envelope.xsd'),
64    SOAP_ENCODING_NAMESPACE: os.path.join(SCHEMAS_DIR, 'WSDL/soap-encoding.xsd'),
65
66    # Remote locations: contributors can propose additional official locations
67    # for other namespaces for extending this list.
68    XSLT_NAMESPACE: os.path.join(SCHEMAS_DIR, 'http://www.w3.org/2007/schema-for-xslt20.xsd'),
69}
70
71
72###
73# Elements and attributes names
74
75_VC_TEMPLATE = '{http://www.w3.org/2007/XMLSchema-versioning}%s'
76_XML_TEMPLATE = '{http://www.w3.org/XML/1998/namespace}%s'
77_XSD_TEMPLATE = '{http://www.w3.org/2001/XMLSchema}%s'
78_XSI_TEMPLATE = '{http://www.w3.org/2001/XMLSchema-instance}%s'
79
80
81#
82# Version Control attributes (XSD 1.1)
83VC_MIN_VERSION = _VC_TEMPLATE % 'minVersion'
84VC_MAX_VERSION = _VC_TEMPLATE % 'maxVersion'
85VC_TYPE_AVAILABLE = _VC_TEMPLATE % 'typeAvailable'
86VC_TYPE_UNAVAILABLE = _VC_TEMPLATE % 'typeUnavailable'
87VC_FACET_AVAILABLE = _VC_TEMPLATE % 'facetAvailable'
88VC_FACET_UNAVAILABLE = _VC_TEMPLATE % 'facetUnavailable'
89
90
91#
92# XML attributes
93XML_LANG = _XML_TEMPLATE % 'lang'
94XML_SPACE = _XML_TEMPLATE % 'space'
95XML_BASE = _XML_TEMPLATE % 'base'
96XML_ID = _XML_TEMPLATE % 'id'
97XML_SPECIAL_ATTRS = _XML_TEMPLATE % 'specialAttrs'
98
99
100#
101# XML Schema Instance attributes
102XSI_NIL = _XSI_TEMPLATE % 'nil'
103XSI_TYPE = _XSI_TEMPLATE % 'type'
104XSI_SCHEMA_LOCATION = _XSI_TEMPLATE % 'schemaLocation'
105XSI_NONS_SCHEMA_LOCATION = _XSI_TEMPLATE % 'noNamespaceSchemaLocation'
106
107
108#
109# XML Schema fully qualified names
110XSD_SCHEMA = _XSD_TEMPLATE % 'schema'
111
112# Annotations
113XSD_ANNOTATION = _XSD_TEMPLATE % 'annotation'
114XSD_APPINFO = _XSD_TEMPLATE % 'appinfo'
115XSD_DOCUMENTATION = _XSD_TEMPLATE % 'documentation'
116
117# Composing schemas
118XSD_INCLUDE = _XSD_TEMPLATE % 'include'
119XSD_IMPORT = _XSD_TEMPLATE % 'import'
120XSD_REDEFINE = _XSD_TEMPLATE % 'redefine'
121XSD_OVERRIDE = _XSD_TEMPLATE % 'override'
122
123# Structures
124XSD_SIMPLE_TYPE = _XSD_TEMPLATE % 'simpleType'
125XSD_COMPLEX_TYPE = _XSD_TEMPLATE % 'complexType'
126XSD_ATTRIBUTE = _XSD_TEMPLATE % 'attribute'
127XSD_ELEMENT = _XSD_TEMPLATE % 'element'
128XSD_NOTATION = _XSD_TEMPLATE % 'notation'
129
130# Grouping
131XSD_GROUP = _XSD_TEMPLATE % 'group'
132XSD_ATTRIBUTE_GROUP = _XSD_TEMPLATE % 'attributeGroup'
133
134# simpleType declaration elements
135XSD_RESTRICTION = _XSD_TEMPLATE % 'restriction'
136XSD_LIST = _XSD_TEMPLATE % 'list'
137XSD_UNION = _XSD_TEMPLATE % 'union'
138
139# complexType content
140XSD_EXTENSION = _XSD_TEMPLATE % 'extension'
141XSD_SEQUENCE = _XSD_TEMPLATE % 'sequence'
142XSD_CHOICE = _XSD_TEMPLATE % 'choice'
143XSD_ALL = _XSD_TEMPLATE % 'all'
144XSD_ANY = _XSD_TEMPLATE % 'any'
145XSD_SIMPLE_CONTENT = _XSD_TEMPLATE % 'simpleContent'
146XSD_COMPLEX_CONTENT = _XSD_TEMPLATE % 'complexContent'
147XSD_ANY_ATTRIBUTE = _XSD_TEMPLATE % 'anyAttribute'
148
149#
150#  Facets (lexical, pre-lexical and value-based facets)
151XSD_ENUMERATION = _XSD_TEMPLATE % 'enumeration'
152XSD_LENGTH = _XSD_TEMPLATE % 'length'
153XSD_MIN_LENGTH = _XSD_TEMPLATE % 'minLength'
154XSD_MAX_LENGTH = _XSD_TEMPLATE % 'maxLength'
155XSD_PATTERN = _XSD_TEMPLATE % 'pattern'              # lexical facet
156XSD_WHITE_SPACE = _XSD_TEMPLATE % 'whiteSpace'       # pre-lexical facet
157XSD_MAX_INCLUSIVE = _XSD_TEMPLATE % 'maxInclusive'
158XSD_MAX_EXCLUSIVE = _XSD_TEMPLATE % 'maxExclusive'
159XSD_MIN_INCLUSIVE = _XSD_TEMPLATE % 'minInclusive'
160XSD_MIN_EXCLUSIVE = _XSD_TEMPLATE % 'minExclusive'
161XSD_TOTAL_DIGITS = _XSD_TEMPLATE % 'totalDigits'
162XSD_FRACTION_DIGITS = _XSD_TEMPLATE % 'fractionDigits'
163
164# XSD 1.1 elements
165XSD_OPEN_CONTENT = _XSD_TEMPLATE % 'openContent'                 # open content model
166XSD_DEFAULT_OPEN_CONTENT = _XSD_TEMPLATE % 'defaultOpenContent'  # default open content model
167XSD_ALTERNATIVE = _XSD_TEMPLATE % 'alternative'                  # conditional type assignment
168XSD_ASSERT = _XSD_TEMPLATE % 'assert'                            # complex type assertions
169XSD_ASSERTION = _XSD_TEMPLATE % 'assertion'                      # facets
170XSD_EXPLICIT_TIMEZONE = _XSD_TEMPLATE % 'explicitTimezone'
171
172# Identity constraints
173XSD_UNIQUE = _XSD_TEMPLATE % 'unique'
174XSD_KEY = _XSD_TEMPLATE % 'key'
175XSD_KEYREF = _XSD_TEMPLATE % 'keyref'
176XSD_SELECTOR = _XSD_TEMPLATE % 'selector'
177XSD_FIELD = _XSD_TEMPLATE % 'field'
178
179#
180# XSD Builtin Types
181
182# Special XSD built-in types.
183XSD_ANY_TYPE = _XSD_TEMPLATE % 'anyType'
184XSD_ANY_SIMPLE_TYPE = _XSD_TEMPLATE % 'anySimpleType'
185XSD_ANY_ATOMIC_TYPE = _XSD_TEMPLATE % 'anyAtomicType'
186
187# Other XSD built-in types.
188XSD_DECIMAL = _XSD_TEMPLATE % 'decimal'
189XSD_STRING = _XSD_TEMPLATE % 'string'
190XSD_DOUBLE = _XSD_TEMPLATE % 'double'
191XSD_FLOAT = _XSD_TEMPLATE % 'float'
192
193XSD_DATE = _XSD_TEMPLATE % 'date'
194XSD_DATETIME = _XSD_TEMPLATE % 'dateTime'
195XSD_GDAY = _XSD_TEMPLATE % 'gDay'
196XSD_GMONTH = _XSD_TEMPLATE % 'gMonth'
197XSD_GMONTH_DAY = _XSD_TEMPLATE % 'gMonthDay'
198XSD_GYEAR = _XSD_TEMPLATE % 'gYear'
199XSD_GYEAR_MONTH = _XSD_TEMPLATE % 'gYearMonth'
200XSD_TIME = _XSD_TEMPLATE % 'time'
201XSD_DURATION = _XSD_TEMPLATE % 'duration'
202
203XSD_QNAME = _XSD_TEMPLATE % 'QName'
204XSD_NOTATION_TYPE = _XSD_TEMPLATE % 'NOTATION'
205XSD_ANY_URI = _XSD_TEMPLATE % 'anyURI'
206XSD_BOOLEAN = _XSD_TEMPLATE % 'boolean'
207XSD_BASE64_BINARY = _XSD_TEMPLATE % 'base64Binary'
208XSD_HEX_BINARY = _XSD_TEMPLATE % 'hexBinary'
209XSD_NORMALIZED_STRING = _XSD_TEMPLATE % 'normalizedString'
210XSD_TOKEN = _XSD_TEMPLATE % 'token'
211XSD_LANGUAGE = _XSD_TEMPLATE % 'language'
212XSD_NAME = _XSD_TEMPLATE % 'Name'
213XSD_NCNAME = _XSD_TEMPLATE % 'NCName'
214XSD_ID = _XSD_TEMPLATE % 'ID'
215XSD_IDREF = _XSD_TEMPLATE % 'IDREF'
216XSD_ENTITY = _XSD_TEMPLATE % 'ENTITY'
217XSD_NMTOKEN = _XSD_TEMPLATE % 'NMTOKEN'
218
219XSD_INTEGER = _XSD_TEMPLATE % 'integer'
220XSD_LONG = _XSD_TEMPLATE % 'long'
221XSD_INT = _XSD_TEMPLATE % 'int'
222XSD_SHORT = _XSD_TEMPLATE % 'short'
223XSD_BYTE = _XSD_TEMPLATE % 'byte'
224XSD_NON_NEGATIVE_INTEGER = _XSD_TEMPLATE % 'nonNegativeInteger'
225XSD_POSITIVE_INTEGER = _XSD_TEMPLATE % 'positiveInteger'
226XSD_UNSIGNED_LONG = _XSD_TEMPLATE % 'unsignedLong'
227XSD_UNSIGNED_INT = _XSD_TEMPLATE % 'unsignedInt'
228XSD_UNSIGNED_SHORT = _XSD_TEMPLATE % 'unsignedShort'
229XSD_UNSIGNED_BYTE = _XSD_TEMPLATE % 'unsignedByte'
230XSD_NON_POSITIVE_INTEGER = _XSD_TEMPLATE % 'nonPositiveInteger'
231XSD_NEGATIVE_INTEGER = _XSD_TEMPLATE % 'negativeInteger'
232
233# Built-in list types
234XSD_IDREFS = _XSD_TEMPLATE % 'IDREFS'
235XSD_ENTITIES = _XSD_TEMPLATE % 'ENTITIES'
236XSD_NMTOKENS = _XSD_TEMPLATE % 'NMTOKENS'
237
238# XSD 1.1 built-in types
239XSD_DATE_TIME_STAMP = _XSD_TEMPLATE % 'dateTimeStamp'
240XSD_DAY_TIME_DURATION = _XSD_TEMPLATE % 'dayTimeDuration'
241XSD_YEAR_MONTH_DURATION = _XSD_TEMPLATE % 'yearMonthDuration'
242XSD_ERROR = _XSD_TEMPLATE % 'error'
243
244XSD_UNTYPED_ATOMIC = _XSD_TEMPLATE % 'untypedAtomic'
245