Question

?PostGIS Array type to GML with XML Templater


Badge

Hi 

I am trying to create GML via the XML Templater transformer - but I am a bit stuck when it comes to creating nested attributes in the resulting GML .
I have data stored in a postgresql table where two columns "changedate" & "reasonforchange" are currently stored as array types e.g. -

 

changedate 

 

character varying[] 

 

reasonforchange

 

character varying[]{1995-12-18,1995-12-19}{Reclassified,Attributes}

Displayed below is an example of the what the desired output GML should look like:

 

<osgb:changeHistory>
             <osgb:changeDate>1995-12-18</osgb:changeDate>
             <osgb:reasonForChange>Reclassified</osgb:reasonForChange>
</osgb:changeHistory>
<osgb:changeHistory>
             <osgb:changeDate>1995-12-19</osgb:changeDate>
             <osgb:reasonForChange>Attributes</osgb:reasonForChange>
</osgb:changeHistory>

 

The array can hold one or many items (as many as 18), but always in pairs. I currently use the AttributteSplitter transformer on the arrary to create a list attribute to pipe into the xml_templater.

I have been using the below expression which does run and produce GML but only adds one attribute NOT MULTIPLE.

{
  for $changedate in fme:get-list-attribute("changedate_list{}")
  return  <osgb:changeHistory>
          <osgb:changeDate>{$changedate}</osgb:changeDate>
          </osgb:changeHistory>   
  }

QUESTIONS

(1) Is using the "attribute splitter" the correct way to create the desired list attribute before entering the xml templater?

(2) How would I modify the above expression in order to get both "changedate" and "reasonforchange" nested between repeated ChangeHistory Tags?

Any help?

Thanks,

Mike


10 replies

Userlevel 2
Badge +17

Hi @mike_gale, It might be better to use a sub template in the XMLTemplater, rather than list iteration. To do that, you will have to add a process to construct a structured list which stores pairs of individual date and reason. e.g. "_list{}.date", "_list{}.reason".

In my poor English, it's hard to explain the process only with words, so I attached a workspace example: structured-list-and-xmltemplater-example.fmw (FME 2015.1.3+)

Please post again if there are insufficient parts. Also I'd like to know if there is any simpler way.

Badge +2

@mike_gale - just wondering why you're using the XMLTemplater to format GML rather than use (what looks like) the OS MasterMap schema with a GML writer?

Building a list as explained by @takashi then writing that directly to OSMM schema GML gives me:

<osgb:changeHistory>
<osgb:changeDate>1995-12-18</osgb:changeDate>
<osgb:reasonForChange>Reclassified</osgb:reasonForChange>
</osgb:changeHistory>
<osgb:changeHistory>
<osgb:changeDate>1995-12-19</osgb:changeDate>
<osgb:reasonForChange>Attributes</osgb:reasonForChange>
</osgb:changeHistory> 

No ListExploder or XMLTemplater! Of course there maybe other reasons but thought I'd chip in.

Userlevel 2
Badge +17

@mike_gale - just wondering why you're using the XMLTemplater to format GML rather than use (what looks like) the OS MasterMap schema with a GML writer?

Building a list as explained by @takashi then writing that directly to OSMM schema GML gives me:

<osgb:changeHistory>
<osgb:changeDate>1995-12-18</osgb:changeDate>
<osgb:reasonForChange>Reclassified</osgb:reasonForChange>
</osgb:changeHistory>
<osgb:changeHistory>
<osgb:changeDate>1995-12-19</osgb:changeDate>
<osgb:reasonForChange>Attributes</osgb:reasonForChange>
</osgb:changeHistory> 

No ListExploder or XMLTemplater! Of course there maybe other reasons but thought I'd chip in.

Hi @mark_1spatial, I didn't realize that the schema is a well known one. I'm interested in the OS MasterMap schema. Can I get the schema file through the Internet?

Badge +2

Hi @mark_1spatial, I didn't realize that the schema is a well known one. I'm interested in the OS MasterMap schema. Can I get the schema file through the Internet?

Hi @takashi

Not sure you'll have much need for OSMM over in your part of the world!

Here is the link to the latest schema

https://www.ordnancesurvey.co.uk/xml/schema/v9/index.html

You can download samples here

https://www.ordnancesurvey.co.uk/business-and-government/licensing/sample-data/discover-data.html

Userlevel 2
Badge +17

Hi @takashi

Not sure you'll have much need for OSMM over in your part of the world!

Here is the link to the latest schema

https://www.ordnancesurvey.co.uk/xml/schema/v9/index.html

You can download samples here

https://www.ordnancesurvey.co.uk/business-and-government/licensing/sample-data/discover-data.html

Thanks for your information! I'll look at the schema to know if it's useful to my part.

Badge

@mike_gale - just wondering why you're using the XMLTemplater to format GML rather than use (what looks like) the OS MasterMap schema with a GML writer?

Building a list as explained by @takashi then writing that directly to OSMM schema GML gives me:

<osgb:changeHistory>
<osgb:changeDate>1995-12-18</osgb:changeDate>
<osgb:reasonForChange>Reclassified</osgb:reasonForChange>
</osgb:changeHistory>
<osgb:changeHistory>
<osgb:changeDate>1995-12-19</osgb:changeDate>
<osgb:reasonForChange>Attributes</osgb:reasonForChange>
</osgb:changeHistory> 

No ListExploder or XMLTemplater! Of course there maybe other reasons but thought I'd chip in.

@mark_1spatial  - Yes this is OSMM. I tried many times using the GML writer and couldn't get it to work. With using the XMLTemplater I managed to get it to work 99%  just couldn't get the the nested changedate and reasonforchange tags.

If you have a sample workbench that I could look at that avoids the XMLTemplater that would be great.

Badge +2

@mark_1spatial - Yes this is OSMM. I tried many times using the GML writer and couldn't get it to work. With using the XMLTemplater I managed to get it to work 99% just couldn't get the the nested changedate and reasonforchange tags.

If you have a sample workbench that I could look at that avoids the XMLTemplater that would be great.

@mike_gale I'll post something later. Keep hold of that existing Workspace as writing GML to a specific structure can be tricky and it might not do exactly what you need.

Badge +2

@mike_gale

Try the following process:

  1. In a blank Workspace add a GML Writer
  2. For the Feature Type Defintion choose Import From Dataset - click OK
  3. In the Import Writer Feature Types dialog it should still be set as Format GML
  4. Click Parameters
  5. For the Application Schema enter: https://www.ordnancesurvey.co.uk/xml/schema/v9/OSDNFFeatures.xsd
  6. Click OK on GML Parameters
  7. Don't choose a Dataset file, just click OK on Import Writer Feature Types
  8. Select the required Feature Types and click OK
  9. Features created onto Workbench Canvas

You'll probably need to set other parameters such as

 

GML srsName

 

Feature Collection

 

Badge +2

@mike_gale

Try the following process:

  1. In a blank Workspace add a GML Writer
  2. For the Feature Type Defintion choose Import From Dataset - click OK
  3. In the Import Writer Feature Types dialog it should still be set as Format GML
  4. Click Parameters
  5. For the Application Schema enter: https://www.ordnancesurvey.co.uk/xml/schema/v9/OSDNFFeatures.xsd
  6. Click OK on GML Parameters
  7. Don't choose a Dataset file, just click OK on Import Writer Feature Types
  8. Select the required Feature Types and click OK
  9. Features created onto Workbench Canvas

You'll probably need to set other parameters such as

 

GML srsName

 

Feature Collection

 

Just to add if you're trying to match OSMM Change Only Update it could get close but maybe not 100%... wouldn't want to take you away from your method if you're already nearly there.

Userlevel 2
Badge +17

Hi @mike_gale, It might be better to use a sub template in the XMLTemplater, rather than list iteration. To do that, you will have to add a process to construct a structured list which stores pairs of individual date and reason. e.g. "_list{}.date", "_list{}.reason".

In my poor English, it's hard to explain the process only with words, so I attached a workspace example: structured-list-and-xmltemplater-example.fmw (FME 2015.1.3+)

Please post again if there are insufficient parts. Also I'd like to know if there is any simpler way.

This custom transformer makes it easier to build a complex list from multiple csv attributes.

Reply