Coverage for gws-app/gws/lib/xmlx/namespace.py: 96%
131 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-17 01:37 +0200
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-17 01:37 +0200
1"""XML namespace manager.
3Maintains a registry of XML namespaces (well-known and custom).
4"""
6from typing import Optional
8import re
10import gws
12from . import error
15def find_by_uri(uri: str) -> Optional[gws.XmlNamespace]:
16 """Locate the Namespace by an Uri.
18 If the Uri ends with a version number, and there is no namespace
19 for this specific Uri, try to locate a non-versioned Uri.
20 That is, ``http://www.opengis.net/gml/9999`` will look up for ``http://www.opengis.net/gml``.
22 Args:
23 uri: An Uri like ``http://www.opengis.net/gml``.
24 Returns:
25 A Namespace.
26 """
28 ns = _INDEX.uri.get(uri)
29 if ns:
30 return ns
32 base_uri, version = _parse_versioned_uri(uri)
33 if version:
34 ns = _INDEX.uri.get(base_uri)
35 if ns:
36 _INDEX.uri[uri] = ns
37 return ns
40def find_by_xmlns(xmlns: str) -> Optional[gws.XmlNamespace]:
41 """Locate the Namespace by a name.
43 Args:
44 xmlns: A name like ``gml``.
46 Returns:
47 A Namespace.
48 """
50 return _INDEX.xmlns.get(xmlns)
53def get(s: str) -> Optional[gws.XmlNamespace]:
54 """Locate the Namespace by a name.
56 Args:
57 s: A uid like ``gml3``, name like ``gml`` or an Uri like ``http://www.opengis.net/gml``.
59 Returns:
60 A Namespace.
61 """
62 return _INDEX.uid.get(s) or _INDEX.xmlns.get(s) or _INDEX.uri.get(s)
65def register(ns: gws.XmlNamespace):
66 """Register a Namespace.
68 Args:
69 ns: Namespace
70 """
72 if ns.uid not in _INDEX.uid:
73 _INDEX.uid[ns.uid] = ns
74 _INDEX.uri[ns.uri] = ns
75 _INDEX.xmlns[ns.xmlns] = ns
78def split_name(name: str) -> tuple[str, str, str]:
79 """Parses an XML name.
81 Args:
82 name: XML name.
84 Returns:
85 A tuple ``(xmlns, uri, proper name)``.
86 """
88 if not name:
89 return '', '', name
91 if name[0] == '{':
92 s = name.split('}')
93 return '', s[0][1:], s[1]
95 if ':' in name:
96 s = name.split(':')
97 return s[0], '', s[1]
99 return '', '', name
102def parse_name(name: str) -> tuple[Optional[gws.XmlNamespace], str]:
103 """Parses an XML name.
105 Args:
106 name: XML name.
108 Returns:
109 A tuple ``(XmlNamespace, proper name)``
110 """
111 xmlns, uri, pname = split_name(name)
113 if xmlns:
114 ns = find_by_xmlns(xmlns)
115 if not ns:
116 raise error.NamespaceError(f'unknown namespace {xmlns!r}')
117 return ns, pname
119 if uri:
120 ns = find_by_uri(uri)
121 if not ns:
122 raise error.NamespaceError(f'unknown namespace uri {uri!r}')
123 return ns, pname
125 return None, pname
128def qualify_name(name: str, ns: gws.XmlNamespace, replace: bool = False) -> str:
129 """Qualifies an XML name.
131 If the name contains a namespace, return as is, otherwise, prepend the namespace.
133 Args:
134 name: An XML name.
135 ns: A namespace.
136 replace: If true, replace the existing namespace.
138 Returns:
139 A qualified name.
140 """
142 ns2, pname = parse_name(name)
143 if ns2 and not replace:
144 return ns2.xmlns + ':' + pname
145 if ns:
146 return ns.xmlns + ':' + pname
147 return pname
150def unqualify_name(name: str) -> str:
151 """Returns an unqualified XML name."""
153 _, _, name = split_name(name)
154 return name
157def unqualify_default(name: str, default_ns: gws.XmlNamespace) -> str:
158 """Removes the default namespace prefix.
160 If the name contains the default namespace, remove it, otherwise return the name as is.
162 Args:
163 name: An XML name.
164 default_ns: A namespace.
166 Returns:
167 The name.
168 """
170 ns, pname = parse_name(name)
171 if ns and ns.uri == default_ns.uri:
172 return pname
173 if ns:
174 return ns.xmlns + ':' + pname
175 return name
178def clarkify_name(name: str) -> str:
179 """Returns an XML name in the Clark notation.
181 Args:
182 name: A qualified XML name.
184 Returns:
185 The XML name in Clark notation.
186 """
188 ns, pname = parse_name(name)
189 if ns:
190 return '{' + ns.uri + '}' + pname
191 return pname
194def declarations(
195 default_ns: Optional[gws.XmlNamespace] = None,
196 for_element: gws.XmlElement = None,
197 extra_ns: Optional[list[gws.XmlNamespace]] = None,
198 with_schema_locations: bool = False,
199) -> dict:
200 """Returns an xmlns declaration block as dictionary of attributes.
202 Args:
203 default_ns: Default namespace.
204 for_element: If given, collect namespaces from this element and its descendants.
205 extra_ns: Extra namespaces to create declarations for.
206 with_schema_locations: Add the "schema location" attribute.
208 Returns:
209 A dict of attributes.
210 """
212 uri_map = {}
214 if for_element:
215 _collect_namespaces(for_element, uri_map)
216 if extra_ns:
217 for ns in extra_ns:
218 uri_map[ns.uri] = ns
219 if default_ns:
220 uri_map[default_ns.uri] = default_ns
222 atts = []
223 schemas = []
225 for ns in uri_map.values():
226 uri = ns.uri
227 if ns.version:
228 uri += '/' + ns.version
230 if default_ns and ns.uri == default_ns.uri:
231 a = _XMLNS
232 else:
233 a = _XMLNS + ':' + ns.xmlns
234 atts.append((a, uri))
236 if with_schema_locations and ns.schemaLocation:
237 schemas.append(ns.uri)
238 schemas.append(ns.schemaLocation)
240 if schemas:
241 atts.append((_XMLNS + ':' + _XSI, _XSI_URL))
242 atts.append((_XSI + ':schemaLocation', ' '.join(schemas)))
244 return dict(sorted(atts))
247def _collect_namespaces(el: gws.XmlElement, uri_map):
248 ns, _ = parse_name(el.tag)
249 if ns:
250 uri_map[ns.uri] = ns
252 for key in el.attrib:
253 ns, _ = parse_name(key)
254 if ns and ns.xmlns != _XMLNS:
255 uri_map[ns.uri] = ns
257 for sub in el:
258 _collect_namespaces(sub, uri_map)
261def _parse_versioned_uri(uri: str) -> tuple[str, str]:
262 m = re.match(r'(.+?)/([\d.]+)$', uri)
263 if m:
264 return m.group(1), m.group(2)
265 return '', uri
268# uid | prefix | preferred version for output | uri | schema location
270_KNOWN_NAMESPACES = """
271xml | | | www.w3.org/XML/1998/namespace |
272html | | | www.w3.org/1999/xhtml |
273wsdl | | | schemas.xmlsoap.org/wsdl |
274xs | | | www.w3.org/2001/XMLSchema |
275xsd | | | www.w3.org/2001/XMLSchema |
276xsi | | | www.w3.org/2001/XMLSchema-instance |
277xlink | | | www.w3.org/1999/xlink | https://www.w3.org/XML/2008/06/xlink.xsd
278rdf | | | www.w3.org/1999/02/22-rdf-syntax-ns |
279soap | | | www.w3.org/2003/05/soap-envelope | https://www.w3.org/2003/05/soap-envelope/
281csw | | 2.0.2 | www.opengis.net/cat/csw | schemas.opengis.net/csw/2.0.2/csw.xsd
282fes | | 2.0 | www.opengis.net/fes | schemas.opengis.net/filter/2.0/filterAll.xsd
284gml2 | gml | 2.1 | www.opengis.net/gml | schemas.opengis.net/gml/2.1.2/gml.xsd
285gml3 | gml | 3.2 | www.opengis.net/gml/3.2 | schemas.opengis.net/gml/3.2.1/gml.xsd
286gml | gml | 3.2 | www.opengis.net/gml/3.2 | schemas.opengis.net/gml/3.2.1/gml.xsd
288gmlcov | | 1.0 | www.opengis.net/gmlcov | schemas.opengis.net/gmlcov/1.0/gmlcovAll.xsd
289ogc | | | www.opengis.net/ogc | schemas.opengis.net/filter/1.1.0/filter.xsd
290ows | | 1.1 | www.opengis.net/ows | schemas.opengis.net/ows/1.0.0/owsAll.xsd
291sld | | | www.opengis.net/sld | schemas.opengis.net/sld/1.1/sldAll.xsd
292swe | | 2.0 | www.opengis.net/swe | schemas.opengis.net/sweCommon/2.0/swe.xsd
293wcs | | 2.0 | www.opengis.net/wcs | schemas.opengis.net/wcs/1.0.0/wcsAll.xsd
294wcscrs | | 1.0 | www.opengis.net/wcs/crs |
295wcsint | | 1.0 | www.opengis.net/wcs/interpolation |
296wcsscal | | 1.0 | www.opengis.net/wcs/scaling |
298wfs | | 2.0 | www.opengis.net/wfs | schemas.opengis.net/wfs/2.0/wfs.xsd
300wms10 | wms | 1.0.0 | www.opengis.net/wms | schemas.opengis.net/wms/1.0.0/capabilities_1_0_0.xml
301wms11 | wms | 1.1.0 | www.opengis.net/wms | schemas.opengis.net/wms/1.1.1/capabilities_1_1_1.xml
302wms13 | wms | 1.3.0 | www.opengis.net/wms | schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd
303wms | wms | 1.3.0 | www.opengis.net/wms | schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd
305wmts | | 1.0 | www.opengis.net/wmts | schemas.opengis.net/wmts/1.0/wmts.xsd
307dc | | 1.1 | purl.org/dc/elements | schemas.opengis.net/csw/2.0.2/rec-dcmes.xsd
308dcm | | | purl.org/dc/dcmitype | dublincore.org/schemas/xmls/qdc/2008/02/11/dcmitype.xsd
309dct | | | purl.org/dc/terms | schemas.opengis.net/csw/2.0.2/rec-dcterms.xsd
311gco | | | www.isotc211.org/2005/gco | schemas.opengis.net/iso/19139/20070417/gco/gco.xsd
312gmd | | | www.isotc211.org/2005/gmd | schemas.opengis.net/csw/2.0.2/profiles/apiso/1.0.0/apiso.xsd
313gmx | | | www.isotc211.org/2005/gmx | schemas.opengis.net/iso/19139/20070417/gmx/gmx.xsd
314srv | | | www.isotc211.org/2005/srv | schemas.opengis.net/iso/19139/20070417/srv/1.0/srv.xsd
316ms | | | http://mapserver.gis.umn.edu/mapserver |
318inspire_dls | | 1.0 | inspire.ec.europa.eu/schemas/inspire_dls | inspire.ec.europa.eu/schemas/inspire_dls/1.0/inspire_dls.xsd
319inspire_ds | | 1.0 | inspire.ec.europa.eu/schemas/inspire_ds | inspire.ec.europa.eu/schemas/inspire_ds/1.0/inspire_ds.xsd
320inspire_vs | | 1.0 | inspire.ec.europa.eu/schemas/inspire_vs | inspire.ec.europa.eu/schemas/inspire_vs/1.0/inspire_vs.xsd
321inspire_vs_ows11 | | 1.0 | inspire.ec.europa.eu/schemas/inspire_vs_ows11 | inspire.ec.europa.eu/schemas/inspire_vs_ows11/1.0/inspire_vs_ows_11.xsd
322inspire_common | | 1.0 | inspire.ec.europa.eu/schemas/common | inspire.ec.europa.eu/schemas/common/1.0/common.xsd
324ac-mf | | 4.0 | inspire.ec.europa.eu/schemas/ac-mf | inspire.ec.europa.eu/schemas/ac-mf/4.0/AtmosphericConditionsandMeteorologicalGeographicalFeatures.xsd
325ac | | 4.0 | inspire.ec.europa.eu/schemas/ac-mf | inspire.ec.europa.eu/schemas/ac-mf/4.0/AtmosphericConditionsandMeteorologicalGeographicalFeatures.xsd
326mf | | 4.0 | inspire.ec.europa.eu/schemas/ac-mf | inspire.ec.europa.eu/schemas/ac-mf/4.0/AtmosphericConditionsandMeteorologicalGeographicalFeatures.xsd
327act-core | | 4.0 | inspire.ec.europa.eu/schemas/act-core | inspire.ec.europa.eu/schemas/act-core/4.0/ActivityComplex_Core.xsd
328ad | | 4.0 | inspire.ec.europa.eu/schemas/ad | inspire.ec.europa.eu/schemas/ad/4.0/Addresses.xsd
329af | | 4.0 | inspire.ec.europa.eu/schemas/af | inspire.ec.europa.eu/schemas/af/4.0/AgriculturalAndAquacultureFacilities.xsd
330am | | 4.0 | inspire.ec.europa.eu/schemas/am | inspire.ec.europa.eu/schemas/am/4.0/AreaManagementRestrictionRegulationZone.xsd
331au | | 4.0 | inspire.ec.europa.eu/schemas/au | inspire.ec.europa.eu/schemas/au/4.0/AdministrativeUnits.xsd
332base | | 3.3 | inspire.ec.europa.eu/schemas/base | inspire.ec.europa.eu/schemas/base/3.3/BaseTypes.xsd
333base2 | | 2.0 | inspire.ec.europa.eu/schemas/base2 | inspire.ec.europa.eu/schemas/base2/2.0/BaseTypes2.xsd
334br | | 4.0 | inspire.ec.europa.eu/schemas/br | inspire.ec.europa.eu/schemas/br/4.0/Bio-geographicalRegions.xsd
335bu-base | | 4.0 | inspire.ec.europa.eu/schemas/bu-base | inspire.ec.europa.eu/schemas/bu-base/4.0/BuildingsBase.xsd
336bu-core2d | | 4.0 | inspire.ec.europa.eu/schemas/bu-core2d | inspire.ec.europa.eu/schemas/bu-core2d/4.0/BuildingsCore2D.xsd
337bu-core3d | | 4.0 | inspire.ec.europa.eu/schemas/bu-core3d | inspire.ec.europa.eu/schemas/bu-core3d/4.0/BuildingsCore3D.xsd
338bu | | 0.0 | inspire.ec.europa.eu/schemas/bu | inspire.ec.europa.eu/schemas/bu/0.0/Buildings.xsd
339cp | | 4.0 | inspire.ec.europa.eu/schemas/cp | inspire.ec.europa.eu/schemas/cp/4.0/CadastralParcels.xsd
340cvbase | | 2.0 | inspire.ec.europa.eu/schemas/cvbase | inspire.ec.europa.eu/schemas/cvbase/2.0/CoverageBase.xsd
341cvgvp | | 0.1 | inspire.ec.europa.eu/schemas/cvgvp | inspire.ec.europa.eu/schemas/cvgvp/0.1/CoverageGVP.xsd
342ef | | 4.0 | inspire.ec.europa.eu/schemas/ef | inspire.ec.europa.eu/schemas/ef/4.0/EnvironmentalMonitoringFacilities.xsd
343el-bas | | 4.0 | inspire.ec.europa.eu/schemas/el-bas | inspire.ec.europa.eu/schemas/el-bas/4.0/ElevationBaseTypes.xsd
344el-cov | | 4.0 | inspire.ec.europa.eu/schemas/el-cov | inspire.ec.europa.eu/schemas/el-cov/4.0/ElevationGridCoverage.xsd
345el-tin | | 4.0 | inspire.ec.europa.eu/schemas/el-tin | inspire.ec.europa.eu/schemas/el-tin/4.0/ElevationTin.xsd
346el-vec | | 4.0 | inspire.ec.europa.eu/schemas/el-vec | inspire.ec.europa.eu/schemas/el-vec/4.0/ElevationVectorElements.xsd
347elu | | 4.0 | inspire.ec.europa.eu/schemas/elu | inspire.ec.europa.eu/schemas/elu/4.0/ExistingLandUse.xsd
348er-b | | 4.0 | inspire.ec.europa.eu/schemas/er-b | inspire.ec.europa.eu/schemas/er-b/4.0/EnergyResourcesBase.xsd
349er-c | | 4.0 | inspire.ec.europa.eu/schemas/er-c | inspire.ec.europa.eu/schemas/er-c/4.0/EnergyResourcesCoverage.xsd
350er-v | | 4.0 | inspire.ec.europa.eu/schemas/er-v | inspire.ec.europa.eu/schemas/er-v/4.0/EnergyResourcesVector.xsd
351er | | 0.0 | inspire.ec.europa.eu/schemas/er | inspire.ec.europa.eu/schemas/er/0.0/EnergyResources.xsd
352gaz | | 3.2 | inspire.ec.europa.eu/schemas/gaz | inspire.ec.europa.eu/schemas/gaz/3.2/Gazetteer.xsd
353ge-core | | 4.0 | inspire.ec.europa.eu/schemas/ge-core | inspire.ec.europa.eu/schemas/ge-core/4.0/GeologyCore.xsd
354ge | | 0.0 | inspire.ec.europa.eu/schemas/ge | inspire.ec.europa.eu/schemas/ge/0.0/Geology.xsd
355ge_gp | | 4.0 | inspire.ec.europa.eu/schemas/ge_gp | inspire.ec.europa.eu/schemas/ge_gp/4.0/GeophysicsCore.xsd
356ge_hg | | 4.0 | inspire.ec.europa.eu/schemas/ge_hg | inspire.ec.europa.eu/schemas/ge_hg/4.0/HydrogeologyCore.xsd
357gelu | | 4.0 | inspire.ec.europa.eu/schemas/gelu | inspire.ec.europa.eu/schemas/gelu/4.0/GriddedExistingLandUse.xsd
358geoportal | | 1.0 | inspire.ec.europa.eu/schemas/geoportal | inspire.ec.europa.eu/schemas/geoportal/1.0/geoportal.xsd
359gn | | 4.0 | inspire.ec.europa.eu/schemas/gn | inspire.ec.europa.eu/schemas/gn/4.0/GeographicalNames.xsd
360hb | | 4.0 | inspire.ec.europa.eu/schemas/hb | inspire.ec.europa.eu/schemas/hb/4.0/HabitatsAndBiotopes.xsd
361hh | | 4.0 | inspire.ec.europa.eu/schemas/hh | inspire.ec.europa.eu/schemas/hh/4.0/HumanHealth.xsd
362hy-n | | 4.0 | inspire.ec.europa.eu/schemas/hy-n | inspire.ec.europa.eu/schemas/hy-n/4.0/HydroNetwork.xsd
363hy-p | | 4.0 | inspire.ec.europa.eu/schemas/hy-p | inspire.ec.europa.eu/schemas/hy-p/4.0/HydroPhysicalWaters.xsd
364hy | | 4.0 | inspire.ec.europa.eu/schemas/hy | inspire.ec.europa.eu/schemas/hy/4.0/HydroBase.xsd
365lc | | 0.0 | inspire.ec.europa.eu/schemas/lc | inspire.ec.europa.eu/schemas/lc/0.0/LandCover.xsd
366lcn | | 4.0 | inspire.ec.europa.eu/schemas/lcn | inspire.ec.europa.eu/schemas/lcn/4.0/LandCoverNomenclature.xsd
367lcr | | 4.0 | inspire.ec.europa.eu/schemas/lcr | inspire.ec.europa.eu/schemas/lcr/4.0/LandCoverRaster.xsd
368lcv | | 4.0 | inspire.ec.europa.eu/schemas/lcv | inspire.ec.europa.eu/schemas/lcv/4.0/LandCoverVector.xsd
369lu | | 4.0 | inspire.ec.europa.eu/schemas/lunom | inspire.ec.europa.eu/schemas/lunom/4.0/LandUseNomenclature.xsd
370lunom | | 4.0 | inspire.ec.europa.eu/schemas/lunom | inspire.ec.europa.eu/schemas/lunom/4.0/LandUseNomenclature.xsd
371mr-core | | 4.0 | inspire.ec.europa.eu/schemas/mr-core | inspire.ec.europa.eu/schemas/mr-core/4.0/MineralResourcesCore.xsd
372mu | | | inspire.ec.europa.eu/schemas/mu/3.0rc3 | inspire.ec.europa.eu/schemas/mu/3.0rc3/MaritimeUnits.xsd
373net | | 4.0 | inspire.ec.europa.eu/schemas/net | inspire.ec.europa.eu/schemas/net/4.0/Network.xsd
374nz-core | | 4.0 | inspire.ec.europa.eu/schemas/nz-core | inspire.ec.europa.eu/schemas/nz-core/4.0/NaturalRiskZonesCore.xsd
375nz | | 0.0 | inspire.ec.europa.eu/schemas/nz | inspire.ec.europa.eu/schemas/nz/0.0/NaturalRiskZones.xsd
376of | | 4.0 | inspire.ec.europa.eu/schemas/of | inspire.ec.europa.eu/schemas/of/4.0/OceanFeatures.xsd
377oi | | 4.0 | inspire.ec.europa.eu/schemas/oi | inspire.ec.europa.eu/schemas/oi/4.0/Orthoimagery.xsd
378omop | | 3.0 | inspire.ec.europa.eu/schemas/omop | inspire.ec.europa.eu/schemas/omop/3.0/ObservableProperties.xsd
379omor | | 3.0 | inspire.ec.europa.eu/schemas/omor | inspire.ec.europa.eu/schemas/omor/3.0/ObservationReferences.xsd
380ompr | | 3.0 | inspire.ec.europa.eu/schemas/ompr | inspire.ec.europa.eu/schemas/ompr/3.0/Processes.xsd
381omso | | 3.0 | inspire.ec.europa.eu/schemas/omso | inspire.ec.europa.eu/schemas/omso/3.0/SpecialisedObservations.xsd
382pd | | 4.0 | inspire.ec.europa.eu/schemas/pd | inspire.ec.europa.eu/schemas/pd/4.0/PopulationDistributionDemography.xsd
383pf | | 4.0 | inspire.ec.europa.eu/schemas/pf | inspire.ec.europa.eu/schemas/pf/4.0/ProductionAndIndustrialFacilities.xsd
384plu | | 4.0 | inspire.ec.europa.eu/schemas/plu | inspire.ec.europa.eu/schemas/plu/4.0/PlannedLandUse.xsd
385ps | | 4.0 | inspire.ec.europa.eu/schemas/ps | inspire.ec.europa.eu/schemas/ps/4.0/ProtectedSites.xsd
386sd | | 4.0 | inspire.ec.europa.eu/schemas/sd | inspire.ec.europa.eu/schemas/sd/4.0/SpeciesDistribution.xsd
387selu | | 4.0 | inspire.ec.europa.eu/schemas/selu | inspire.ec.europa.eu/schemas/selu/4.0/SampledExistingLandUse.xsd
388so | | 4.0 | inspire.ec.europa.eu/schemas/so | inspire.ec.europa.eu/schemas/so/4.0/Soil.xsd
389sr | | 4.0 | inspire.ec.europa.eu/schemas/sr | inspire.ec.europa.eu/schemas/sr/4.0/SeaRegions.xsd
390su-core | | 4.0 | inspire.ec.europa.eu/schemas/su-core | inspire.ec.europa.eu/schemas/su-core/4.0/StatisticalUnitCore.xsd
391su-grid | | 4.0 | inspire.ec.europa.eu/schemas/su-grid | inspire.ec.europa.eu/schemas/su-grid/4.0/StatisticalUnitGrid.xsd
392su-vector | | 4.0 | inspire.ec.europa.eu/schemas/su-vector | inspire.ec.europa.eu/schemas/su-vector/4.0/StatisticalUnitVector.xsd
393su | | 0.0 | inspire.ec.europa.eu/schemas/su | inspire.ec.europa.eu/schemas/su/0.0/StatisticalUnits.xsd
394tn-a | | 4.0 | inspire.ec.europa.eu/schemas/tn-a | inspire.ec.europa.eu/schemas/tn-a/4.0/AirTransportNetwork.xsd
395tn-c | | 4.0 | inspire.ec.europa.eu/schemas/tn-c | inspire.ec.europa.eu/schemas/tn-c/4.0/CableTransportNetwork.xsd
396tn-ra | | 4.0 | inspire.ec.europa.eu/schemas/tn-ra | inspire.ec.europa.eu/schemas/tn-ra/4.0/RailwayTransportNetwork.xsd
397tn-ro | | 4.0 | inspire.ec.europa.eu/schemas/tn-ro | inspire.ec.europa.eu/schemas/tn-ro/4.0/RoadTransportNetwork.xsd
398tn-w | | 4.0 | inspire.ec.europa.eu/schemas/tn-w | inspire.ec.europa.eu/schemas/tn-w/4.0/WaterTransportNetwork.xsd
399tn | | 4.0 | inspire.ec.europa.eu/schemas/tn | inspire.ec.europa.eu/schemas/tn/4.0/CommonTransportElements.xsd
400ugs | | 0.0 | inspire.ec.europa.eu/schemas/ugs | inspire.ec.europa.eu/schemas/ugs/0.0/UtilityAndGovernmentalServices.xsd
401us-emf | | 4.0 | inspire.ec.europa.eu/schemas/us-emf | inspire.ec.europa.eu/schemas/us-emf/4.0/EnvironmentalManagementFacilities.xsd
402us-govserv | | 4.0 | inspire.ec.europa.eu/schemas/us-govserv | inspire.ec.europa.eu/schemas/us-govserv/4.0/GovernmentalServices.xsd
403us-net-common | | 4.0 | inspire.ec.europa.eu/schemas/us-net-common | inspire.ec.europa.eu/schemas/us-net-common/4.0/UtilityNetworksCommon.xsd
404us-net-el | | 4.0 | inspire.ec.europa.eu/schemas/us-net-el | inspire.ec.europa.eu/schemas/us-net-el/4.0/ElectricityNetwork.xsd
405us-net-ogc | | 4.0 | inspire.ec.europa.eu/schemas/us-net-ogc | inspire.ec.europa.eu/schemas/us-net-ogc/4.0/OilGasChemicalsNetwork.xsd
406us-net-sw | | 4.0 | inspire.ec.europa.eu/schemas/us-net-sw | inspire.ec.europa.eu/schemas/us-net-sw/4.0/SewerNetwork.xsd
407us-net-tc | | 4.0 | inspire.ec.europa.eu/schemas/us-net-tc | inspire.ec.europa.eu/schemas/us-net-tc/4.0/TelecommunicationsNetwork.xsd
408us-net-th | | 4.0 | inspire.ec.europa.eu/schemas/us-net-th | inspire.ec.europa.eu/schemas/us-net-th/4.0/ThermalNetwork.xsd
409us-net-wa | | 4.0 | inspire.ec.europa.eu/schemas/us-net-wa | inspire.ec.europa.eu/schemas/us-net-wa/4.0/WaterNetwork.xsd
410wfd | | 0.0 | inspire.ec.europa.eu/schemas/wfd | inspire.ec.europa.eu/schemas/wfd/0.0/WaterFrameworkDirective.xsd
411"""
413##
415_XMLNS = 'xmlns'
416_XSI = 'xsi'
417_XSI_URL = 'http://www.w3.org/2001/XMLSchema-instance'
420class _Index:
421 uid = {}
422 xmlns = {}
423 uri = {}
426_INDEX = _Index()
428# fake namespace for 'xmlns:'
429_INDEX.uid[_XMLNS] = _INDEX.xmlns[_XMLNS] = gws.XmlNamespace(uid=_XMLNS, xmlns=_XMLNS, uri='', schemaLocation='', version='')
432def _load_known():
433 for ln in _KNOWN_NAMESPACES.strip().split('\n'):
434 ln = ln.strip()
435 if not ln or ln.startswith('#'):
436 continue
437 uid, xmlns, version, uri, schema = [s.strip() for s in ln.split('|')]
438 xmlns = xmlns or uid
439 uri = 'http://' + uri
440 if schema:
441 schema = 'http://' + schema
442 register(gws.XmlNamespace(uid=uid, xmlns=xmlns, uri=uri, schemaLocation=schema, version=version))
445_load_known()