Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: Transform XML to another XML with 100% same structure but enriching only the values

  1. #1
    Join Date
    Dec 2016
    Posts
    1

    Default Transform XML to another XML with 100% same structure but enriching only the values

    Hey All,

    I am new to Pentaho transformations and I am unable to achieve what i believe should be very simple to achieve.

    I get an input XML from a source system which I need to send to a target system after enriching few values.

    Sample Example. let say i receive the below
    Code:
    <Event>
      <RetryCount>0</RetryCount>
      <MalwareData>
         <guid>0F00</guid>
         <max_severity>0</max_severity>
      </MalwareData>
    </Event>
    I need to read this XML and change the value for RetryCount, change the value for max_severity and send it forward to next system in the exact same format as shown below

    Code:
    <Event>
      <RetryCount>12</RetryCount>
      <MalwareData>
         <guid>0F00</guid>
         <max_severity>95</max_severity>
      </MalwareData>
    </Event>
    However I am unable to do that.

    I have tried using below input and output but none of them give me exact same xml, all of them either remove the main tags, forexample <MalwareData> gets removed, <Event> gets removed , or some would add tags like <row> etc

    I have tried using inputs like "Get data from XML", "XML Input Stream" and output like "XML Output"

    Can you please let me know how do i achieve this simple transformation?

    Regards,
    Rohit
    Last edited by jstrosh; 12-09-2016 at 12:16 AM.

  2. #2

    Default

    Use XML Input Stream (StAX) and then filter against the xml_path to change the xml_data_value based on the xml_data_name

  3. #3
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Modification of existing XML documents is typically done with step XSLT-Transform.
    So long, and thanks for all the fish.

  4. #4
    Join Date
    Aug 2011
    Posts
    360

    Default

    In this particular example, you could just do a string replace using regular expressions

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
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.