BRGM / gml_application_schema_toolbox

GML Application Schema toolbox is a QGIS plugin allowing to manipulate OGC Complex Features
https://brgm.github.io/gml_application_schema_toolbox/
GNU General Public License v2.0
28 stars 18 forks source link

error to import in generic xml mode (Prefix format reserved for internal use) #83

Open geostonemarten opened 5 years ago

geostonemarten commented 5 years ago

Can you overload xml before import for all key use and reserved to your internal use?

What key are reseved?

Stacktrace Python:

2019-05-29T08:33:37     WARNING    Traceback (most recent call last):
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\gui\load_wizard_xml.py", line 58, in validatePage
              swap_xy=self.swapXYCheck.isChecked())
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 59, in load_as_xml_layer
              return s.load_complex_gml(xml_uri, is_remote, attributes, geometry_mapping, logger, swap_xy)
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 317, in load_complex_gml
              src = ComplexFeatureSource(xml_src, attributes, geometry_mapping, logger)
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 198, in __init__
              doc, _ = xml_parse(xml)
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\xml_utils.py", line 94, in xml_parse
              ET.register_namespace(prefix, uri)
              File "C:\OSGEO4~1\apps\Python37\lib\xml\etree\ElementTree.py", line 1035, in register_namespace
              raise ValueError("Prefix format reserved for internal use")
             ValueError: Prefix format reserved for internal use

2019-05-29T08:36:57     WARNING    Traceback (most recent call last):
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\gui\load_wizard_xml.py", line 58, in validatePage
              swap_xy=self.swapXYCheck.isChecked())
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 59, in load_as_xml_layer
              return s.load_complex_gml(xml_uri, is_remote, attributes, geometry_mapping, logger, swap_xy)
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 317, in load_complex_gml
              src = ComplexFeatureSource(xml_src, attributes, geometry_mapping, logger)
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 198, in __init__
              doc, _ = xml_parse(xml)
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\xml_utils.py", line 94, in xml_parse
              ET.register_namespace(prefix, uri)
              File "C:\OSGEO4~1\apps\Python37\lib\xml\etree\ElementTree.py", line 1035, in register_namespace
              raise ValueError("Prefix format reserved for internal use")
             ValueError: Prefix format reserved for internal use

2019-05-29T08:37:50     WARNING    Traceback (most recent call last):
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\gui\load_wizard_xml.py", line 58, in validatePage
              swap_xy=self.swapXYCheck.isChecked())
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 59, in load_as_xml_layer
              return s.load_complex_gml(xml_uri, is_remote, attributes, geometry_mapping, logger, swap_xy)
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 317, in load_complex_gml
              src = ComplexFeatureSource(xml_src, attributes, geometry_mapping, logger)
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gml_as_xml.py", line 198, in __init__
              doc, _ = xml_parse(xml)
              File "C:/Users/x/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\xml_utils.py", line 94, in xml_parse
              ET.register_namespace(prefix, uri)
              File "C:\OSGEO4~1\apps\Python37\lib\xml\etree\ElementTree.py", line 1035, in register_namespace
              raise ValueError("Prefix format reserved for internal use")
             ValueError: Prefix format reserved for internal use
mhugo commented 5 years ago

@geostonemarten Apparently, the constraint comes from ElementTree, the Python XML library. From what I can read in the source code, any namespace that is named ns followed by a number is reserved.

geostonemarten commented 5 years ago

Ok this is a language limite. Can you overload namespace if ns* is detected in the source file?

nmtoken commented 4 years ago

@geostonemarten did you mean deleted rather than detected ?

I was getting the error with a file with the following prefixes:

<gml:FeatureCollection 
    xmlns:lc="urn:x-inspire:specification:gmlas:LandCover:0.0"
    xmlns:sr="urn:x-inspire:specification:gmlas:SeaRegions:0.0"
    xmlns:nrz="urn:x-inspire:specification:gmlas:NaturalRiskZones:0.0"
    xmlns:gco="http://www.isotc211.org/2005/gco"
    xmlns:hfp="http://www.w3.org/2001/XMLSchema-hasFacetAndProperty"
    xmlns:wfd="urn:x-inspire:specification:gmlas:WaterFrameworkDirective:0.0"
    xmlns:gml="http://www.opengis.net/gml/3.2" 
    xmlns:ns1="http://www.w3.org/1999/xhtml"
    xmlns:hy="urn:x-inspire:specification:gmlas:HydroBase:3.0"
    xmlns:hy-n="urn:x-inspire:specification:gmlas:HydroNetwork:3.0"
    xmlns:gmd="http://www.isotc211.org/2005/gmd"
    xmlns:hy-p="urn:x-inspire:specification:gmlas:HydroPhysicalWaters:3.0"
    xmlns:net="urn:x-inspire:specification:gmlas:Network:3.2"
    xmlns:gsr="http://www.isotc211.org/2005/gsr" 
    xmlns:gts="http://www.isotc211.org/2005/gts"
    xmlns:gn="urn:x-inspire:specification:gmlas:GeographicalNames:3.0"
    xmlns:xlink="http://www.w3.org/1999/xlink" 
    xmlns:gss="http://www.isotc211.org/2005/gss"
    xmlns:base="urn:x-inspire:specification:gmlas:BaseTypes:3.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    gml:id="_64fcbf57-4712-471b-941a-a32bf099cb3a"
    xsi:schemaLocation="urn:x-inspire:specification:gmlas:HydroPhysicalWaters:3.0 http://inspire.ec.europa.eu/schemas/hy-p/3.0/HydroPhysicalWaters.xsd http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/deprecatedTypes.xsd">

Changing xmlns:ns1="http://www.w3.org/1999/xhtml" to xmlns:ns_1="http://www.w3.org/1999/xhtml" resolves the issue