Skip to main content
Archived

Add Attributes to Expose parameter to XMLXQueryExploder

Related products:Transformers
nielsgerrits
geomancer
danilo_fme
sigtill
crutledge
+2
  • nielsgerrits
    nielsgerrits
  • geomancer
    geomancer
  • danilo_fme
    danilo_fme
  • sigtill
    sigtill
  • crutledge
    crutledge
  • sigher
    sigher
  • liamfez
    liamfez

takashi
Influencer

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 a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, 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.

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