Skip to main content


Hi,


I’m looking for some help please, if anyone can respond...


I’m using FME 2016 to transform data into INSPIRE gml for
the administrativeBoundaries theme and I’m new to the world of xml.


I’ve looked at several examples on FME Knowledge for
XMLTemplater but cannot get the values to write back as I want.


My source data is a geodatabase with linestring data
containing references to their related polygons.


In FME I have concatenated these reference values for each
ID , into one attribute, admUnit. Values are comma separated. I then use AttributeSplitter and ListExploder to
expose the list, admUnit_list{}. The list length varies for different ID but never
be empty.






AdministrativeBoundary.localID1admUnitRef1,Ref5,Ref6,Ref7admUnit_list{0}Ref1admUnit_list{1}Ref5admUnit_list{2}Ref6admUnit_list{3}Ref7


I want my final output as INSPIRE gml
using the administrativeBoundary schema to resemble


<gml:featureMember>


<au:AdministrativeBoundary
gml:id="ID1">


<au:admUnit
xlink:href="Ref1"/>


<au:admUnit
xlink:href="Ref5"/>


<au:admUnit
xlink:href="Ref6"/>


<au:admUnit
xlink:href="Ref7"/>


</au:AdministrativeBoundary>


</gml:featureMember>



I cannot get this output and due to a
lack of experience with xml cannot work out what I am doing wrong...


I have tried two methods
unsuccessfully



Method 1:


In xmlTemplater in the Root Template I have


{


for $admUnit in
{fme:get-list-attribute("admUnit_list{}")}


return


<admUnit>{$admUnit}</admUnit>


}



I am writing the output from
xmlTemplater to the attribute admUnit_result.



This gives me a one line output


admUnit_result (encoded: utf-8):
<admUnit>Ref1</admUnit><admUnit>Ref5</admUnit><admUnit>Ref6</admUnit><admUnit>Ref7</admUnit>



I then use AttributeCopier to map admUnit_result
to admUnit{0}.xlink_href


This writes to the gml file as


<gml:featureMember>


<au:AdministrativeBoundary
gml:id="GB.NI.LPS.AU.L_1">


<au:admUnit
xlink:href="<admUnit>Ref1</admUnit><admUnit>Ref5</


admUnit><admUnit>Ref6</admUnit><admUnit>Ref7</admUnit>"/>


</au:AdministrativeBoundary>


</gml:featureMember>



Question


1. How can I get this to resemble the
gml output above where each value has a separate line?


2. How do I remove the < and
> to give < and > respectively?



Method2:


In xmlTemplater if I set the root to


<root>


{fme:process-features("SUB")}


</root>



And the sub template to


<admUnit>


{


for $admUnit in {fme:get-list-attribute("admUnit_list{}")}


return


<admUnit>{$admUnit}</admUnit>


}


</admUnit>



The returned attribute, admUnit_result, shows empty values when viewed
in Inspector.





AdministrativeBoundary.localID

1admUnitRef1,Ref5,Ref6,Ref7admUnit_list{0}Ref1admUnit_list{1}Ref5admUnit_list{2}Ref6admUnit_list{3}Ref7admUnit_resultadmUnit_result (encoded: utf-8):
<root><admUnit></admUnit><admUnit></admUnit><admUnit></admUnit><admUnit></admUnit></root>


And in the gml file the admUnit
element is similar with no values


<gml:featureMember>


<au:admUnit
xlink:href="<root>


<admUnit>



</admUnit><admUnit>



</admUnit>


</root>"/>


</au:AdministrativeBoundary>


</gml:featureMember>



Question


How do I get the values to output?



Does anyone have a solution please?



Thanks.

If you are exploding the list, why use the list element in your xml templater? try using the attribute that contains the list element value after exploding the list.


@itay

 

the total number of attributes in the real list varies.

 

I was using xmlTemplater to perform iteration (or loop for each id) as the maximum number of values varies for each ID and the target gml requires a single entry.

 

I was attempting to write the values with the xml tags to an a single attribute so it would map easily to gml and the tags would give new lines.

Yes what you suggest works but it is cumbersome.

 

If I use the attribute created from exploding the list I need to enter a value range, so I need to know the maximum number of values in the list and then individually map these as the target gml attribute requests a single value.

 

This is creating empty entries in the gml as some Ids can have 2 attribute values, others have more.

In the data I also have a similar mapping to perform where the maximum number of options is large for each ID and I really do not want to have to do this mapping manually so if I can find a way to do iteration successfully it would be good.

Thanks for your answer.


@itay

 

the total number of attributes in the real list varies.

 

I was using xmlTemplater to perform iteration (or loop for each id) as the maximum number of values varies for each ID and the target gml requires a single entry.

 

I was attempting to write the values with the xml tags to an a single attribute so it would map easily to gml and the tags would give new lines.

Yes what you suggest works but it is cumbersome.

 

If I use the attribute created from exploding the list I need to enter a value range, so I need to know the maximum number of values in the list and then individually map these as the target gml attribute requests a single value.

 

This is creating empty entries in the gml as some Ids can have 2 attribute values, others have more.

In the data I also have a similar mapping to perform where the maximum number of options is large for each ID and I really do not want to have to do this mapping manually so if I can find a way to do iteration successfully it would be good.

Thanks for your answer.

I understand you better now, would it be possible to create the tag by concatenating the list elements (listConcatenator) into a new attribute and then use that attribute in the templater?

 

 


I would strongly recommend using the INSPIRE GML writer rather than the XMLTemplater / Text File writer for writing or reading any EU INSPIRE data. We've invested a lot to fully support GML application schema based writing in order to better support complex schemas such as INSPIRE.

In this case, you need to select and add the INSPIRE writer and then select to add the AdministrativeBoundary destination feature type. In this feature type you will see admUnit{}.xlink_href. You will need to create a valid AdministrativeBoundary feature with the required properties such as inspireId etc. Then you will need to add a list to this feature called admUnit{}.xlink_href with values:

admUnit_list{0} = Ref1

admUnit_list{1} = Ref2

etc. For more info see: https://knowledge.safe.com/articles/775/inspire-gml-basic-writing-example.html

I believe you have a support case in our system so I will follow up there. If not, please contact us via http://www.safe.com/support/ for further assistance with this.


Reply