Results 1 to 6 of 6

Thread: How to insert data in xml

  1. #1

    Post How to insert data in xml

    Hi,
    I am designing one SI project.in the flow there is one field that needed to be hardcoded .Is there way i can insert data in the filed.The file is a type of XML.

    Eg.in the below file i need to insert the country filed from SI flow.I want an alternative to service activator
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
     <person>
               <name>xyz</name>
                <country></country>
      </person>
    Thanks
    Vishal

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Vishal

    What you are describing is a classic example of Content Enricher EIP pattern which is realized in Spring Integration via transformer. So it is as simple as implementing a regular transformer which receives XML you described and outputs XML with a new field.

  3. #3

    Post

    Hi oleg,

    My problem here is little bit complicated

    I have an input file to input channel(input) and there is field in the i/p file say country name,but we cannot have it transformed in the transformation but we need that data for the thirdTransformation. is there any way we can store that data in header and retrive it later and add it in xml

    My transformation logic:
    Code:
    <int:transformer id="firstTransformation" input-channel="input" output-channel="output">
     <!--  some transformation  -->
     </int:transformer>
     
      <int:transformer id="secondTransformation" input-channel="output" output-channel="output1">
     <!--  some transformation  -->
     </int:transformer>
     
     <int:transformer id="thirdTransformation" input-channel="output1" output-channel="output2">
     <!--  some transformation  -->
     </int:transformer>
    vishal

  4. #4
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Yes, its kind of the same thing but you would use Header Enricher component

  5. #5

    Default

    can you please provide a sample snippet.

  6. #6
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    The sample is in the link i included in the previous post:
    Code:
    <int:header-enricher input-channel="in" output-channel="out">
         <int:header name="foo" value="123"/>
         <int:header name="bar" ref="someBean"/>
    </int:header-enricher>
    In the above the Message that came in to the 'in' channel will be enriched with two additional headers 'foo' and 'bar' with corresponding values.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •