top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Informatica Powercenter: How to run a XSLT transform on a XML document

+1 vote
856 views

I have a complex XML document that the informatica XML parser struggles with "normalizing", how can I run a XML transformation such as XSLT to simplfy it prior to sending it into the XML parser.

posted Sep 10, 2014 by Sunil

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

One way of doing this is to use the standard Java transform and use the standard javax.xml.transform API to perform the transformation.

To do this add a Java Transform to your flow
enter image description here

In the Import Packages pane, import the required java packages

enter image description here

import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;

In the Helper Code pane we construct a transformer object. As I understand non static fields are created per instance, so there should be no concurrency issues. (comments?)

enter image description here

private final Transformer transformer = getNewTransformer();

public Transformer getNewTransformer()
{ 
  // /opt/informatica/infadev/DataTransformation
  final String IFCMPath = System.getenv("IFCONTENTMASTER_HOME"); 
  final String xslt = IFCMPath + "/ServiceDB/xst/mytransform.xslt";
  logInfo("Using XSLT File" + xslt);
  try{
   return TransformerFactory.newInstance().newTransformer(new StreamSource(xslt));
  } catch(TransformerConfigurationException ex) {
    logError("Could not create TransformerFactory with xslt " + xslt );

  }
  return null;
}

Finally we execute the transform on the incoming xml document by executing the transform method on the transformer object.

enter image description here

if( transformer == null ) {
    failSession("Transformer was null");
}

//final long startTime = System.nanoTime();
//final long endTime;

try {
    //logInfo("Recieved xml with size " + xmlin.length() );
    // logInfo("Recieved xml " + xmlin );
    final StringReader reader = new StringReader(xmlin);
    final StringWriter writer = new StringWriter();

    transformer.transform(new StreamSource(reader),new StreamResult(writer));
    xmlout = writer.toString();
   // logInfo("xmlout  " + xmlout  );
} catch (Exception e) {
     incrementErrorCount(1);
     logError(e.getMessage());
     logError(xmlin);
} 

//finally { 
//  endTime = System.nanoTime(); 
//} 

//final long duration = endTime - startTime; 
//logInfo("Duration  " + duration / **********.0 );
answer Sep 12, 2014 by Shweta Singh
Similar Questions
+2 votes

When we do not know the number of targets, Can we create the targets at run time using informatica Powercenter.

Suppose we have below source:
Employee:

Dept_ID      EmpName  Sal
10           A        200
11           B        100
10           C        200
10           D        400
12           E        500
12           F        400

...

It can have any number of distinct Dept_ID. I want to load all EmpName and Sal of a particular Dept_ID into a separate target table (i.e target name should be as Tar_10 or Tar_11 where 10 & 11 are Dept_ID).

+1 vote

In Informatica's PowerCenter, is it possible to set a parameter's value based on the output of a stored procedure? The parameter I want to set is a parameter I defined in a flat-file data object.

+1 vote

How to transform rows into column using Normalizer in Informatica?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...