Skip to content

Commit

Permalink
GMLAS: implement resolution of internal xlink:href='#....' references (
Browse files Browse the repository at this point in the history
…fixes BRGM/gml_application_schema_toolbox#31)

git-svn-id: https://svn.osgeo.org/gdal/trunk@40973 f0d54148-0727-0410-94bb-9a71ac55c965
  • Loading branch information
rouault committed Dec 7, 2017
1 parent 517fd83 commit 75d32a8
Show file tree
Hide file tree
Showing 19 changed files with 1,070 additions and 251 deletions.
31 changes: 31 additions & 0 deletions autotest/ogr/data/gmlas/gmlas_internal_xlink_href.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<FeatureCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://fake_xlink"
xsi:noNamespaceSchemaLocation="gmlas_internal_xlink_href.xsd">
<main_elt>
<link_to_second_or_third_elt xlink:href="#does_not_exist"/>
</main_elt>
<main_elt>
<link_to_second_or_third_elt xlink:href="#id2"/>
</main_elt>
<main_elt>
<link_to_second_or_third_elt xlink:href="#id3"/>
</main_elt>
<main_elt>
<link_to_second_or_third_elt xlink:href="#id4"/>
</main_elt>
<main_elt>
<link_to_third_elt xlink:href="#id4"/>
</main_elt>
<main_elt>
<link_to_second_or_third_elt>
<second_elt id="id1"/>
</link_to_second_or_third_elt>
</main_elt>

<second_elt id="id2"/>

<second_elt id="id3"/>

<third_elt id="id4"/>

</FeatureCollection>
58 changes: 58 additions & 0 deletions autotest/ogr/data/gmlas/gmlas_internal_xlink_href.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xlink="http://fake_xlink"
elementFormDefault="qualified" attributeFormDefault="unqualified">

<xs:import namespace="http://fake_xlink" schemaLocation="gmlas_fake_xlink.xsd"/>

<xs:element name="FeatureCollection">
<xs:complexType>
<xs:sequence>
<xs:element ref="main_elt" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="second_elt" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="third_elt" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="main_elt">
<xs:complexType>
<xs:sequence>
<xs:element name="link_to_second_or_third_elt" minOccurs="0">
<xs:complexType>
<xs:sequence minOccurs="0">
<xs:any processContents="lax"/>
</xs:sequence>
<xs:attribute ref="xlink:href"/>
</xs:complexType>
</xs:element>
<xs:element name="link_to_third_elt" minOccurs="0">
<xs:complexType>
<xs:sequence minOccurs="0">
<xs:element ref="third_elt"/>
</xs:sequence>
<xs:attribute ref="xlink:href"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="second_elt">
<xs:complexType>
<xs:sequence>
<xs:element name="foo" type="xs:string" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="id" type="xs:ID" use="required"/>
</xs:complexType>
</xs:element>

<xs:element name="third_elt">
<xs:complexType>
<xs:sequence>
<xs:element name="foo" type="xs:string" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="id" type="xs:ID"/>
</xs:complexType>
</xs:element>

</xs:schema>
5 changes: 4 additions & 1 deletion autotest/ogr/data/gmlas/gmlas_test_targetelement.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<gml:FeatureCollection
xmlns:myns="http://myns"
xmlns:other_ns="http://other_ns"
xmlns:gml="http://fake_gml"
xmlns:xlink="http://fake_xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand All @@ -8,8 +9,10 @@
<myns:main_elt>
<myns:reference_missing_target_elt xlink:href="#FOO"/>
<myns:reference_inexisting_target_elt xlink:href="#BAR"/>
<myns:reference_existing_target_elt xlink:href="#BAZ"/>
<myns:reference_existing_target_elt_with_required_id xlink:href="#BAZ"/>
<myns:reference_existing_target_elt_with_optional_id xlink:href="#BAZ2"/>
<myns:reference_existing_abstract_target_elt xlink:href="#BAW"/>
<myns:reference_existing_abstract_target_elt_nillable xsi:nil="true"/>
</myns:main_elt>
<other_ns:target_elt_with_optional_id id="BAZ2"/>
</gml:FeatureCollection>
12 changes: 10 additions & 2 deletions autotest/ogr/data/gmlas/gmlas_test_targetelement.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@
</xs:annotation>
</xs:element>

<xs:element name="reference_existing_target_elt" type="gml:ReferenceType" minOccurs="0">
<xs:element name="reference_existing_target_elt_with_required_id" type="gml:ReferenceType" minOccurs="0">
<xs:annotation>
<xs:appinfo>
<targetElement xmlns="http://fake_gml">other_ns:existing_target_elt</targetElement>
<targetElement xmlns="http://fake_gml">other_ns:target_elt_with_required_id</targetElement>
</xs:appinfo>
</xs:annotation>
</xs:element>

<xs:element name="reference_existing_target_elt_with_optional_id" type="gml:ReferenceType" minOccurs="0">
<xs:annotation>
<xs:appinfo>
<targetElement xmlns="http://fake_gml">other_ns:target_elt_with_optional_id</targetElement>
</xs:appinfo>
</xs:annotation>
</xs:element>
Expand Down
14 changes: 12 additions & 2 deletions autotest/ogr/data/gmlas/gmlas_test_targetelement_other_ns.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@

<xs:import namespace="http://fake_gml" schemaLocation="gmlas_test_targetelement_fake_gml.xsd"/>

<xs:element name="existing_target_elt" substitutionGroup="gml:_Feature">
<xs:element name="target_elt_with_required_id" substitutionGroup="gml:_Feature">
<xs:complexType>
<xs:sequence>
<xs:element name="attr" type="xs:string"/>
<xs:element name="attr" type="xs:string" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="id" type="xs:ID" use="required"/>
</xs:complexType>
</xs:element>

<xs:element name="target_elt_with_optional_id" substitutionGroup="gml:_Feature">
<xs:complexType>
<xs:sequence>
<xs:element name="attr" type="xs:string" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="id" type="xs:ID"/>
</xs:complexType>
</xs:element>

Expand Down
6 changes: 6 additions & 0 deletions autotest/ogr/data/gmlas/real_world/output/EUReg.example.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ OGRFeature(productionfacility):1
beginlifespanversion (DateTime) = (null)
hostingsite_href (String) = #_123456789.SITE
hostingsite_owns (Integer(Boolean)) = 0
hostingsite_productionsite_eureg_productionsite_pkid (String) = _123456789.SITE
facilityname_owns (Integer(Boolean)) = 0
facilityname_featurename_nameoffeature (String) = EXAMPLE FACILITY 1
facilityname_featurename_confidentialityreason_owns (Integer(Boolean)) = 0
Expand Down Expand Up @@ -200,12 +201,14 @@ OGRFeature(productionfacility_groupedinstallation):1
parent_id (String) = _000000002.FACILITY
href (String) = #_010101011.INSTALLATION
owns (Integer(Boolean)) = 0
productioninstallation_eureg_productioninstallation_pkid (String) = _010101011.INSTALLATION

OGRFeature(productionfacility_groupedinstallation):2
ogr_pkid (String) = _000000002.FACILITY_groupedInstallation_2
parent_id (String) = _000000002.FACILITY
href (String) = #_010101012.INSTALLATION
owns (Integer(Boolean)) = 0
productioninstallation_eureg_productioninstallation_pkid (String) = _010101012.INSTALLATION


Layer name: productionfacility_competentauthorityeprtr
Expand Down Expand Up @@ -368,12 +371,14 @@ OGRFeature(eureg_productioninstallation_groupedinstallationpart):1
parent_id (String) = _010101011.INSTALLATION
href (String) = #_987654321.PART
owns (Integer(Boolean)) = 0
productioninstallatipart_eureg_productioninstallatipart_pkid (String) = _987654321.PART

OGRFeature(eureg_productioninstallation_groupedinstallationpart):2
ogr_pkid (String) = _010101012.INSTALLATION_groupedInstallationPart_2
parent_id (String) = _010101012.INSTALLATION
href (String) = #_987654322.PART
owns (Integer(Boolean)) = 0
productioninstallatipart_eureg_productioninstallatipart_pkid (String) = _987654322.PART


Layer name: eureg_productioninstallation_competentauthoritypermits
Expand Down Expand Up @@ -633,6 +638,7 @@ OGRFeature(eureg_productionsite):1
sitename_featurename_confidentialityreason_owns (Integer(Boolean)) = 0
reportdata_href (String) = #ES.RD.2017
reportdata_owns (Integer(Boolean)) = 0
reportdata_reportdata_pkid (String) = ES.RD.2017
eureg_location = POINT (2.104334 41.991925)


Expand Down
Loading

0 comments on commit 75d32a8

Please sign in to comment.