Question

Trying to read GML with multiple elements.

  • 30 April 2014
  • 5 replies
  • 7 views

Badge
Hello all,

 

 

I'm new here (and to FME!) so apologies in advance if this is a silly question.

 

 

I'm trying to read some GML files associated with some aerial imagery files I have.

 

 

The scheme of the GML files is defined by http://www.ordnancesurvey.co.uk/xml/namespaces/osgb OSOrthoMetadata.xsd

 

 

I want to create a .csv file containing columns for KmReference, dateFlown and Resolution for a series of files but I'm having difficulty configuring FME to read the dateFlown.

 

 

This is defined here:

 

http://www.centremapslive.co.uk/files/osmmuserguide.pdf

 

"There will be one dateFlown element if the

 

image was flown on a single day, or two

 

dateFlown elements representing the first and

 

last dates flown. Dates have the format of:

 

CCYY-MM-DD."

 

 

...so I think the problem is handling multiple elements. This seems to be confirmed by the fact that my sequence of GML Reader, Attribute Creater and CSV Writer is able read and write out the DateOfCompletion to my .CSV. DateOfCompletion only ever has 1 element.

 

 

Please can anyone advise on an approach to handle potential multiple dateFlown elements and return the single element or the latest date if multiple elements are present?

 

 

Many thanks in advance,

 

 

Matt

5 replies

Userlevel 4
Hi,

 

 

it might be worth testing the XML reader in FME, in particular using feature paths (http://fmepedia.safe.com/articles/How_To/Reading-XML).

 

 

You could also consider posting a single entry with dual dateFlown elements here, it would make it easier to give a specific answer.

 

 

David
Badge
Hi David,

 

 

 

Many thanks for your really quick response :-)

 

 

 

I've got this working now using the feature paths configuration type on the XML reader as suggested in the link that you posted.

 

 

 

However, if the GML file has a single dateFlown element then this is read fine by FME but my Data inspector shows that if there are two dateFlown elements the attribute is <missing>. Below are example XML documents containg single and double dateFlown elements.

 

 

Single:

 

 

<?xml version="1.0" encoding="utf-8" ?>

 

- <osgb:OrthoImageMetadata xsi:schemaLocation="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb OSOrthoMetadata.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgb="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb">

 

  <osgb:copyright>Copyright GeoPerspectives 1999-2009</osgb:copyright>

 

  <osgb:kmReference>SD8824</osgb:kmReference>

 

  <osgb:dateFlown>2009-05-30</osgb:dateFlown>

 

- <osgb:kmRectangle>

 

- <osgb:Rectangle srsName="osgb:BNG">

 

  <gml:coordinates xmlns:gml="http://www.opengis.net/gml">388000,424000,389000,425000</gml:coordinates>

 

  </osgb:Rectangle>

 

  </osgb:kmRectangle>

 

  <osgb:lensFocalLength uom="http://www.ordnancesurvey.co.uk/xml/resource/units.xml#millimetres">100.5</osgb:lensFocalLength>

 

  <osgb:nominalFlyingHeight uom="http://www.ordnancesurvey.co.uk/xml/resource/units.xml#metres">1900</osgb:nominalFlyingHeight>

 

  <osgb:nominalImageScale>1:18905</osgb:nominalImageScale>

 

  <osgb:nominalAbsoluteAccuracy uom="http://www.ordnancesurvey.co.uk/xml/resource/units.xml#metres">1</osgb:nominalAbsoluteAccuracy>

 

  <osgb:resolution uom="http://www.ordnancesurvey.co.uk/xml/resource/units.xml#metres">0.1</osgb:resolution>

 

  <osgb:fileSize uom="http://www.ordnancesurvey.co.uk/xml/resource/units.xml#MegaBytes">292.98</osgb:fileSize>

 

  <osgb:control>Orthorectified</osgb:control>

 

  <osgb:createdBy>GeoPerspectives</osgb:createdBy>

 

  <osgb:correctionType>Orthorectified</osgb:correctionType>

 

  <osgb:dateOfCompletion>2009-08-18</osgb:dateOfCompletion>

 

- <osgb:derivedFromAerialPhoto>

 

  <osgb:filmId>n/a</osgb:filmId>

 

  <osgb:frameNumber>n/a</osgb:frameNumber>

 

  </osgb:derivedFromAerialPhoto>

 

  </osgb:OrthoImageMetadata>

 

 

Double:

 

 

<?xml version="1.0" encoding="utf-8" ?>

 

- <osgb:OrthoImageMetadata xsi:schemaLocation="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb OSOrthoMetadata.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgb="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb">

 

  <osgb:copyright>Copyright GeoPerspectives 1999-2009</osgb:copyright>

 

  <osgb:kmReference>SD9132</osgb:kmReference>

 

  <osgb:dateFlown>2009-05-30</osgb:dateFlown>

 

  <osgb:dateFlown>2009-06-01</osgb:dateFlown>

 

- <osgb:kmRectangle>

 

- <osgb:Rectangle srsName="osgb:BNG">

 

  <gml:coordinates xmlns:gml="http://www.opengis.net/gml">391000,432000,392000,433000</gml:coordinates>

 

  </osgb:Rectangle>

 

  </osgb:kmRectangle>

 

  <osgb:lensFocalLength uom="http://www.ordnancesurvey.co.uk/xml/resource/units.xml#millimetres">100.5</osgb:lensFocalLength>

 

  <osgb:nominalFlyingHeight uom="http://www.ordnancesurvey.co.uk/xml/resource/units.xml#metres">1900</osgb:nominalFlyingHeight>

 

  <osgb:nominalImageScale>1:18905</osgb:nominalImageScale>

 

  <osgb:nominalAbsoluteAccuracy uom="http://www.ordnancesurvey.co.uk/xml/resource/units.xml#metres">1</osgb:nominalAbsoluteAccuracy>

 

  <osgb:resolution uom="http://www.ordnancesurvey.co.uk/xml/resource/units.xml#metres">0.1</osgb:resolution>

 

  <osgb:fileSize uom="http://www.ordnancesurvey.co.uk/xml/resource/units.xml#MegaBytes">292.98</osgb:fileSize>

 

  <osgb:control>Orthorectified</osgb:control>

 

  <osgb:createdBy>GeoPerspectives</osgb:createdBy>

 

  <osgb:correctionType>Orthorectified</osgb:correctionType>

 

  <osgb:dateOfCompletion>2009-08-18</osgb:dateOfCompletion>

 

- <osgb:derivedFromAerialPhoto>

 

  <osgb:filmId>n/a</osgb:filmId>

 

  <osgb:frameNumber>n/a</osgb:frameNumber>

 

  </osgb:derivedFromAerialPhoto>

 

  </osgb:OrthoImageMetadata>

 

 

Can you offer any further pointers?

 

 

Thanks,

 

 

Matt

 

 

 

Userlevel 2
Badge +17
Hi Matt,

 

 

Multiple child elements will be read as elements of a list attribute. After selecting row of the feature in the Table View of Data Inspector, have a look at Feature Information window.

 

 

Takashi
Badge
Hi Takashi,

 

 

Thank you for your answer. I too can see those elements as list attributes in the data inspector.

 

 

If you select the row of a feature that only has a single dateFlown element in the Table View, then in the Feature Information window only an attribute named dateFlown i.e. not followed by a {0}.

 

 

Therefore, my next questions are:

 

 

1. Which transformer do I need to get the dateFlown{0} (or dateFlown{1}) element of a list attribute so I can set the value to an attribute? I've tried the ListRangeExtractor but it does not recognise any of my input attributes as lists.

 

 

2. Can I get FME to recognise whether there's just a single dateFlown attribute of whether dateFlown{0} and dateFlown{1} elements exist? In the first case I'd just output the dateFlown and in the 2nd case I'd want dateFlown{0}.

 

 

Thanks again,

 

 

Matt
Badge
Hi Takashi,

 

Many, many thanks for your detailed reply. I've got it sorted now. I doubt very much whether I would have found the cardinality settings without your help.

 

Thanks again,

 

Matt

Reply