Solved

Exclude reading XML nodes based on attribute value

  • 4 December 2018
  • 4 replies
  • 7 views

Badge +1

Hello,

I would like to know if there is a syntax in the XML reader “Elements to exclude” option for excluding a node when it has a specific attribute value. For instance I would like to skip reading all nodes "complexAttribute" which have an attributeType equal to "TTOM-Name:Name.Body" such as in this example node:

<complexAttribute attributeId="ee823867-532f-4fca-83ad-6dd9f8df7524" attributeType="TTOM-Name:Name.Body">

</complexAttribute>

 

Such nodes could be present at different levels inside the XML. If these are skipped (because they contribute for a significant part of the XML volume and are not necessary for my process), then it will be easier for me to flatten the XML structure using a series of ListExploders for the remaining nodes.

Thanks for your hints!

Olivier

icon

Best answer by lauraatsafe 5 December 2018, 00:38

View original

4 replies

Badge +6

Hi @olivier,

I got some advice from a couple of our XML experts here. Sounds like this should be possible to do by using an xfMap expression in the 'Elements to Match' parameter of your XML Reader.

Try setting the 'Elements to Match' to the following:

complexAttribute[@attributeType!='TTOM-Name:Name.Body']

This should map all "complexAttribute" elements except those that have 'attributeType' set to "TTOM-Name:Name.Body"

Here's a link to the documentation on how xfMaps work: http://docs.safe.com/fme/2018.1/html/FME_Desktop_Documentation/FME_ReadersWriters/xml/Match_and_Except_Express.htm

Badge +1

Hi @olivier,

I got some advice from a couple of our XML experts here. Sounds like this should be possible to do by using an xfMap expression in the 'Elements to Match' parameter of your XML Reader.

Try setting the 'Elements to Match' to the following:

complexAttribute[@attributeType!='TTOM-Name:Name.Body']

This should map all "complexAttribute" elements except those that have 'attributeType' set to "TTOM-Name:Name.Body"

Here's a link to the documentation on how xfMaps work: http://docs.safe.com/fme/2018.1/html/FME_Desktop_Documentation/FME_ReadersWriters/xml/Match_and_Except_Express.htm

Thank you @LauraAtSafe ! This should set me on the right path. I guess though that this expression will only act on the node level of the parent features. It will not act on all child nodes (I have quite many node levels using “complexAttribute”). The xfMaps doc will probably suggest what to do in my specific situation.

Userlevel 2
Badge +17

Hi @olivier,

I got some advice from a couple of our XML experts here. Sounds like this should be possible to do by using an xfMap expression in the 'Elements to Match' parameter of your XML Reader.

Try setting the 'Elements to Match' to the following:

complexAttribute[@attributeType!='TTOM-Name:Name.Body']

This should map all "complexAttribute" elements except those that have 'attributeType' set to "TTOM-Name:Name.Body"

Here's a link to the documentation on how xfMaps work: http://docs.safe.com/fme/2018.1/html/FME_Desktop_Documentation/FME_ReadersWriters/xml/Match_and_Except_Express.htm

If you need to exclude the nodes from flattening operations, try setting the expression to the Sub-Elements To Ignore parameter in the Flatten Options dialog.

Badge +1

If you need to exclude the nodes from flattening operations, try setting the expression to the Sub-Elements To Ignore parameter in the Flatten Options dialog.

Thank you Takashi!

Reply