Skip to main content
Solved

Exclude reading XML nodes based on attribute value

  • December 4, 2018
  • 4 replies
  • 137 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

View original
Did this help you find an answer to your question?

4 replies

laurawatsafe
Safer
Forum|alt.badge.img+11
  • Safer
  • 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
  • December 5, 2018
lauraatsafe wrote:

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
Influencer
  • December 6, 2018
lauraatsafe wrote:

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
  • December 10, 2018
takashi wrote:

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!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings