Skip to main content
Archived

Add Attributes to Expose parameter to XMLXQueryExploder

Related products:Transformers
  • March 10, 2018
  • 0 replies
  • 22 views

takashi
Celebrity

Imagine a case where the source XML document has more complex structure and every <record> element contains much more child elements than shown in the below, and you need to fragment the document into individual record but want only preserve a few attributes. e.g. only "id" and "attr1" are necessary in the subsequent process.

<records>     <record id="1">         <attr1>11</attr1>         <attr2>12</attr2>     </record>     <record id="2">         <attr1>21</attr1>         <attr2>22</attr2>     </record> </records> 

You can do that using the XMLFragmenter with Flattening Options followed by the AttributeKeeper etc..

[Edit] My bad. I thought the XMLXQueryExploder with this XQuery expression could perform that more efficiently, but it doesn't work as expected in fact. I don't know why, but the fme:set-attribute function in the expression seems to retrieve the value of <attr1> element under the last <record> element always.

for $r in //record return {      xs:string($r/@id),     fme:set-attribute('attr1', $r/attr1/text()) } 

Also, the transformer has Remove Source XML Attribute? parameter now, but the source XML attribute name won't be hidden even if you set Yes to the parameter. I hope the attribute name could also be hidden.

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.