Skip to main content

Hi Everyone,

 

I have recently started with FME. I have a case where I have to format an XML from a list. 

I am using XMLTemplater Transformer to build a request xml which looks like below

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wnb="http://sample.com.au">
   <soapenv:Header/>
   <soapenv:Body>
      <wnb:fetchNotificationDetails>
         <!--1 or more repetitions:-->
         <notificationNo>121</notificationNo>
         <notificationNo>131</notificationNo>
     <notificationNo>141</notificationNo>
      </wnb:fetchNotificationDetails>
   </soapenv:Body>
</soapenv:Envelope>

 

 

 I am passing some ten notification numbers to a XML templater and they are coming out individually like below 

 

   <soapenv:Header/>
   <soapenv:Body>
      <wnb:fetchNotificationDetails>
         <!--1 or more repetitions:-->
         <notificationNo>301</notificationNo> 
      </wnb:fetchNotificationDetails>
   </soapenv:Body>
</soapenv:Envelope>

 

 <soapenv:Header/>
   <soapenv:Body>
      <wnb:fetchNotificationDetails>
         <!--1 or more repetitions:-->
         <notificationNo>302</notificationNo> 
      </wnb:fetchNotificationDetails>
   </soapenv:Body>
</soapenv:Envelope>

 

I used a listbuilder transformer and then passed it to XMLTemplater .

 

What is the option I should select from the below to read a list to form request XML mentioned below


I want a single output from XML templater which looks like below

 

 <soapenv:Header/>
   <soapenv:Body>
      <wnb:fetchNotificationDetails>
         <!--1 or more repetitions:-->
         <notificationNo>121</notificationNo>
         <notificationNo>131</notificationNo>
     <notificationNo>141</notificationNo>
      </wnb:fetchNotificationDetails>
   </soapenv:Body>
</soapenv:Envelope>

 

Any help would be appreciated. Thanks

 

 

II would solve this by using a creator for the root element, then inside the root element use process-features to get your list of notification ID’s. So something like this:

where the Root Template Expression is this:

<Body>
<fetchNotificationDetails>
{fme:process-features("NOTIFICATION_IDS")}
</fetchNotificationDetails>
</Body>

And the Sub Template NOTIFICATION_IDS looks like this:

<notificationNo>{fme:get-attribute("NotificationID")}</notificationNo>

When I run this, this gives me the following XML Result:

<?xml version="1.0" encoding="UTF-8"?>
<Body>
<fetchNotificationDetails>
<notificationNo>0</notificationNo>
<notificationNo>1</notificationNo>
<notificationNo>2</notificationNo>
<notificationNo>3</notificationNo>
<notificationNo>4</notificationNo>
<notificationNo>5</notificationNo>
<notificationNo>6</notificationNo>
<notificationNo>7</notificationNo>
<notificationNo>8</notificationNo>
<notificationNo>9</notificationNo>
</fetchNotificationDetails>
</Body>

Which seems to be what you are looking for. Of course my example is a bit simplifed, you’ll need to include the namespaces and stuff, but this should get you going.

 


Hi s.jager ,

 

Thanks for your response and that really helped. I am able to send  all the notifications in a single call.

Thanks a lot.

May I ask you another query related to response,  I get a response for the above notification request as below

<notificationDetails>
            <notificationNo>121</notificationNo>
            <notificationStatus>Found</notificationStatus>
            <jobType>SF</jobType>
            <jobDescription>Test</jobDescription>
            <flNumber>110</flNumber>
         </notificationDetails>
         <notificationDetails>
            <notificationNo>131</notificationNo>
            <notificationStatus>Found</notificationStatus>
            <jobType>SF</jobType>
            <jobDescription>Test</jobDescription>
            <flNumber>111</flNumber>
         </notificationDetails>
         <notificationDetails>
            <notificationNo>141</notificationNo>
            <notificationStatus>Not Found</notificationStatus>
            <jobType></jobType>
            <jobDescription></jobDescription>
            <flNumber></flNumber>
         </notificationDetails>

 

Is there anyway that I can get the output in to rows like below

 

NotificationNo notificationStatus jobType jobDescription flNumber
121 Found SF Test 110


Is there a transformer I can use to do that ?
Thanks again for your help. :)


I’m not sure what you mean by 

get the output in to rows

You wanted xml, that’s what you get. And you already have the features with the attributes, so that is already in sort of a tabular format. Do you want to see it in the Data Explorer? Then just add an Inspector right in front of the XMLTemplater. Or do you also want an excel or an html table as secondary output?


Hi s.jager,

 

Thanks for your response.

I want to extract the attributes of the response xml for further processing.

 

If below is my response xml, 

<notificationDetails>
            <notificationNo>121</notificationNo>
            <notificationStatus>Found</notificationStatus>
            <jobType>SF</jobType>
            <jobDescription>Test</jobDescription>
            <flNumber>110</flNumber>
         </notificationDetails>
         <notificationDetails>
            <notificationNo>131</notificationNo>
            <notificationStatus>Found</notificationStatus>
            <jobType>SF</jobType>
            <jobDescription>Test</jobDescription>
            <flNumber>111</flNumber>
         </notificationDetails>
         <notificationDetails>
            <notificationNo>141</notificationNo>
            <notificationStatus>Not Found</notificationStatus>
            <jobType></jobType>
            <jobDescription></jobDescription>
            <flNumber></flNumber>
         </notificationDetails>

 

 I have to take each one of these notification IDS and respective job type, job desc etc to query another table and get some other information. 
 

NotificationNo notificationStatus jobType jobDescription flNumber

121

122

Found

Not Found

SF

SK

Test
Testq

110

112

 

I tried using AttributeExploder to extract the attribute values. But that is not giving me the expected result,

I hope I made it a little clear now. 


Ah, that makes more sense, thank you for clearing that up.

To create features from the response xml, the XMLFragmenter is probably your best option.


Reply