1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 """Classes and global objects related to built-in U{XML Namespaces<http://www.w3.org/TR/2006/REC-xml-names-20060816/index.html>}."""
16
17 import pyxb
18
19
20 BuiltInObjectUID = pyxb.utils.utility.UniqueIdentifier('PyXB-' + pyxb.__version__ + '-Builtin')
21
22 from pyxb.namespace import Namespace
23
25 """Extension of L{Namespace} that pre-defines components available in the
26 XMLSchema Instance namespace."""
27
41
42 -class _XML (Namespace):
43 """Extension of L{Namespace} that pre-defines components available in the
44 XML (xml) namespace. Specifically those are the attribute declarations:
45
46 - C{xml:space}
47 - C{xml:lang}
48 - C{xml:base}
49 - C{xml:id}
50
51 the encompassing attribute group declaration:
52
53 - C{xml:specialAttrs}
54
55 and the anonymous types that support these."""
56
58 """Ensure this namespace is ready for use.
59
60 Overrides base class implementation, since there is no schema
61 for this namespace. """
62
63 assert structures_module is not None
64 import pyxb.binding.datatypes as xsd
65 import pyxb.binding.facets as xsdf
66 import archive
67
68 self.configureCategories([archive.NamespaceArchive._AnonymousCategory()])
69
70 schema = structures_module.Schema(namespace_context=self.initialNamespaceContext(), schema_location="URN:noLocation:PyXB:XML", generation_uid=BuiltInObjectUID, _bypass_preload=True)
71
72 std_space = structures_module.SimpleTypeDefinition._CreateXMLInstance('space', schema)
73 std_space._setAnonymousName(self, anon_name='STD_ANON_space')
74 std_space._setBindingNamespace(self)
75 std_lang = structures_module.SimpleTypeDefinition._CreateXMLInstance('lang', schema)
76 std_lang._setAnonymousName(self, anon_name='STD_ANON_lang')
77 std_lang._setBindingNamespace(self)
78
79 base = schema._addNamedComponent(structures_module.AttributeDeclaration.CreateBaseInstance('base', schema, std=xsd.anyURI.SimpleTypeDefinition()))
80 id = schema._addNamedComponent(structures_module.AttributeDeclaration.CreateBaseInstance('id', schema, std=xsd.ID.SimpleTypeDefinition()))
81 space = schema._addNamedComponent(structures_module.AttributeDeclaration.CreateBaseInstance('space', schema, std=std_space))
82 lang = schema._addNamedComponent(structures_module.AttributeDeclaration.CreateBaseInstance('lang', schema, std=std_lang))
83
84 specialAttrs = schema._addNamedComponent(structures_module.AttributeGroupDefinition.CreateBaseInstance('specialAttrs', schema, [
85 structures_module.AttributeUse.CreateBaseInstance(schema, space),
86 structures_module.AttributeUse.CreateBaseInstance(schema, base),
87 structures_module.AttributeUse.CreateBaseInstance(schema, lang),
88 structures_module.AttributeUse.CreateBaseInstance(schema, id),
89 ]))
90
91 return self
92
94 """Extension of L{Namespace} that pre-defines components available in the
95 XMLSchema namespace.
96
97 The types are defined when L{pyxb.xmlschema.structures} is imported.
98 """
99
116
117 XMLSchema_instance = _XMLSchema_instance('http://www.w3.org/2001/XMLSchema-instance',
118 description='XML Schema Instance',
119 builtin_namespace='XMLSchema_instance')
120 """Namespace and URI for the XMLSchema Instance namespace. This is always
121 built-in, and does not (cannot) have an associated schema."""
122
123 XMLNamespaces = Namespace('http://www.w3.org/2000/xmlns/',
124 description='Namespaces in XML',
125 builtin_namespace='XMLNamespaces',
126 bound_prefix='xmlns')
127 """Namespaces in XML. Not really a namespace, but is always available as C{xmlns}."""
128
129
130 XMLSchema = _XMLSchema('http://www.w3.org/2001/XMLSchema',
131 description='XML Schema',
132 builtin_namespace='XMLSchema',
133 builtin_module_path='pyxb.binding.datatypes',
134 in_scope_namespaces = { 'xs' : None })
135 """Namespace and URI for the XMLSchema namespace (often C{xs}, or C{xsd})"""
136
137
138 XHTML = Namespace('http://www.w3.org/1999/xhtml',
139 description='Family of document types that extend HTML',
140 builtin_namespace='XHTML',
141 default_namespace=XMLSchema)
142 """There really isn't a schema for this, but it's used as the default
143 namespace in the XML schema, so define it."""
144
145
146 XML = _XML('http://www.w3.org/XML/1998/namespace',
147 description='XML namespace',
148 builtin_namespace='XML',
149 builtin_module_path='pyxb.binding.xml_',
150 is_undeclared_namespace=True,
151 bound_prefix='xml',
152 default_namespace=XHTML,
153 in_scope_namespaces = { 'xs' : XMLSchema })
154 """Namespace and URI for XML itself (always available as C{xml})"""
155
156
157 XMLSchema_hfp = Namespace('http://www.w3.org/2001/XMLSchema-hasFacetAndProperty',
158 description='Facets appearing in appinfo section',
159 builtin_namespace='XMLSchema_hfp',
160 default_namespace=XMLSchema,
161 in_scope_namespaces = { 'hfp' : None
162 , 'xhtml' : XHTML })
163 """Elements appearing in appinfo elements to support data types."""
164
165
166 BuiltInNamespaces = [
167 XMLSchema_instance,
168 XMLSchema_hfp,
169 XMLSchema,
170 XMLNamespaces,
171 XML,
172 XHTML
173 ]
174
175 __InitializedBuiltinNamespaces = False
176
188
189
190 _UndeclaredNamespaceMap = { }
191 [ _UndeclaredNamespaceMap.setdefault(_ns.boundPrefix(), _ns) for _ns in BuiltInNamespaces if _ns.isUndeclaredNamespace() ]
192