Skip to main content
Solved

Exclude reading XML nodes based on attribute value

  • December 4, 2018
  • 4 replies
  • 180 views

olivier
Contributor
Forum|alt.badge.img+7

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

Best answer by laurawatsafe

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

laurawatsafe
Safer
Forum|alt.badge.img+12
  • Safer
  • 158 replies
  • Best Answer
  • December 4, 2018

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


olivier
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • 60 replies
  • December 5, 2018

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.


takashi
Celebrity
  • 7843 replies
  • December 6, 2018

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.


olivier
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • 60 replies
  • December 10, 2018

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!