Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#5418 closed enhancement (fixed)

GML enhancement proposal: Getting all XML attributes as OGR fields

Reported by: peifer Owned by: warmerdam
Priority: normal Milestone: 1.11.0
Component: OGR_SF Version: unspecified
Severity: normal Keywords: gml attributes


I suggest to have a config option like: GML_ATTRIBUTES_TO_OGR_FIELDS where possible values are a list of elements or ALL, similar to the legal values for config option GML_SKIP_RESOLVE_ELEMS.

The new option would obviously influence how the .gfs files are written. I recently used FME which has this useful option as a built-in.

Change History (5)

comment:1 by Jukka Rahkonen, 10 years ago

Is this something that you can't do with -sql "select field1,field2,field4 from source_layer"?

comment:2 by peifer, 10 years ago


Thanks for looking into the proposal. Maybe I wasn't clear enough or I am missing something. My proposal is about how the GML driver would make an initial scan through an unknown GML structure with unknown XML element names and unknown XML attributes.

The GML driver does the following currently:

--- snip ---

The first time a GML file is opened, if the associated .xsd is absent or could not been parsed correctly, it is completely scanned in order to determine the set of featuretypes, the attributes associated with each and other dataset level information. This information is stored in a .gfs file ..., quoted from

--- snip ---

The very helpful auto-detection as described above currently covers the content (= character data) of XML elements, but not their attribute values. In other words, the generated .gfs template has a lot of <ElementPath>name</ElementPath> and similar, but not a single auto-detected <ElementPath>name@lang</ElementPath> . At least I wouldn't know how to influence the auto-detection in order to tell me what XML attributes have been found.

comment:3 by Even Rouault, 10 years ago

Component: defaultOGR_SF
Keywords: gml attributes added
Milestone: 1.11.0
Resolution: fixed
Status: newclosed

trunk r27120 "GML: autodiscover all XML attributes as OGR fields when creating .gfs file if GML_ATTRIBUTES_TO_OGR_FIELDS is set to YES (#5418)"

comment:4 by peifer, 10 years ago

Thanks for taking care.

In a test file [1] where area is an XML element and uom is an attribute of area, I do get the expected result:

  area (Integer) = 6
  area_uom (String) = km2

The related section of the gfs is:


I would have expected <ElementPath>area@uom</ElementPath>, but both '_' and '@' seem to work fine as path separators.


comment:5 by Even Rouault, 10 years ago

uom attribute handling already pre-existed as a special case. Hence the behaviour you observe.

Note: See TracTickets for help on using tickets.