Hello everyone reading this. I am new to gml conversion, so I seek help here.
I am trying to read gml files provided with xsd schemas, validate them, insert those data into PostGIS database, do some database processing, then exporting data from database into gml files using same xsd schema (meaning output file should be more or less copy of input gml file, with less or more features)
Importing gml files into PostGIS database is going fine, however I have several problems with exporting data, as the files differ in several places and I am unable to figure out how to duplicate the structure.
Unfortunately I cannot provide xsd file and have to use modified gml, sorry :(
I have several problems:
gml file looks like this (change extension, website did not allow me to upload gml):
1) FeatureCollection attributes.
snippet of xsd:
<xs:element name="FeatureCollection" type="eczr:FeatureCollectionType" substitutionGroup="gml:AbstractGML"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="FeatureMember">
<xs:complexType>
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureMemberType">
<xs:sequence>
<xs:element ref="gml:AbstractFeature"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="constructionCode" type="xs:string" use="required"/>
<xs:attribute name="schemaVersion" type="xs:string" use="required"/>
<xs:attribute name="creatorName" type="xs:string" use="required"/>
<xs:attribute name="creatorVersion" type="xs:string" use="required"/>
<xs:attribute name="surveyedFrom" type="xs:date"/>
<xs:attribute name="surveyedTo" type="xs:date"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
Input gml file has this FeatureCollection element:
<FeatureCollection xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.xsd" schemaVersion="2018.0901.0" constructionCode="AAA" creatorName="SW" creatorVersion="1.6.2.101" surveyedFrom="2018-12-06" surveyedTo="2018-12-17" xmlns="http://www.customer.cz" gml:id="20">
in database, I have those attributes stored just fine, I read them just fine (constructionCode, schemaVersion, creatorName, creatorVersion, surveyedFrom, surveyedTo). In worbench I have featuretype "FeatureCollection", when I pass it to the writer with xsd, it manages to get gml:id attribute, however loses every other attribute. Is there a setting I am missing? Every other feature type is created with attributes just fine.
2) Empty attributes
snippet of xsd:
<xs:element name="stavzar" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="25"/>
<xs:enumeration value="a"/>
<xs:enumeration value="b"/>
<xs:enumeration value="c"/>
<xs:enumeration value="d"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Means, that feature can have 0 occurences of the attribute, which happens. When I import a feature, that does not contain this attribute into the database, column "stavzar" is created with "null" value. However when I export this feature, element <stavzar/> is created (empty element) - however when I validate the file I get '...on line 3036, column 22: 'value '' not in enumeration' error, meaning the validator sees the empty value, checks enumeration where empty value is not defined and throws an error. Is there a way that gml writer does not create elements, when their value is "null"?
3) Final problem: namespace.
Is there a way in writer settings to replace / disable namespace from elements?
<eczr:FeatureMember>
<eczr:Pomocne_popisy dmcode="POL.PomocnePopisy" gml:id="1">
<eczr:OGC_GEOMETRY>
<gml:Point gml:id="elid_17_4101" srsName="urn:ogc:def:crs:EPSG:5514">
<gml:pos srsDimension="2">-624378.060000 -1177805.210000</gml:pos>
</gml:Point>
</eczr:OGC_GEOMETRY>
<eczr:OGC_ANGLE uom="radian">1.229934</eczr:OGC_ANGLE>
<eczr:OGC_TEXTJUST>LB</eczr:OGC_TEXTJUST>
<eczr:OGC_TEXT>schody</eczr:OGC_TEXT>
<eczr:emsid>2</eczr:emsid>
<eczr:stav>stávající</eczr:stav>
</eczr:Pomocne_popisy>
</eczr:FeatureMember>
I get that "eczr" is taken from xsd, however is there a way to generate that gml without "eczr" at the beggining of each element?
Thanks for any help in advance,
Radek