Using XSLT for Transformation
An XSLT transformation simulates the original message structure, then specifies how to treat nodes within that structure. You can:
-
Copy the original content of a node without changing anything.
-
Define and insert a new version of a node.
-
Enter any structure or content directly.
-
Eliminate a node by omitting reference to it, or by not inserting anything new in its place.
XSLT Transformation Example
The XSLT wrapper is required.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
The primary node tag matches the original message structure by matching its top level content tag, the message name (QE_SYNC_MSG). Between the message template tags, you can insert any structure or content you want. PeopleSoft Integration Broker replaces each xsl tag with the data it references, producing a transformed message as the output of the step.
<xsl:template match="QE_SYNC_MSG">
<QE_SYNC_MSG>
<xsl:copy-of select="FieldTypes"/>
<MsgData>
<Transaction>
<xsl:apply-templates select="MsgData/Transaction/QE_SALES_ORDER"/>
<xsl:copy-of select="MsgData/Transaction/PSCAMA"/>
</Transaction>
</MsgData>
</QE_SYNC_MSG>
</xsl:template>
The following node example is defined to match a record in the input message by its top level content tag, the record name (QE_SALES_ORDER). This template is applied by the xsl:apply-templates tag of the preceding node (shown emphasized).
Between the record template tags, you can insert any structure or content you want. In this example, 90 is prepended to the QE_ACCT_ID value, and the QE_ACCOUNT_NAME field is renamed to QE_ACCOUNT (shown emphasized). Also, any existing value in the DESCRLONG field is removed, and the remaining fields are passed through with their original values.
<xsl:template match="QE_SALES_ORDER">
<QE_SALES_ORDER><xsl:attribute name="class">
<xsl:value-of select="@class"/></xsl:attribute>
<xsl:variable name="temp" select="QE_ACCT_ID"/>
<QE_ACCT_ID><xsl:value-of select="concat(90,$temp)"/></QE_ACCT_ID><QE_ACCOUNT><xsl:value-of select="QE_ACCOUNT_NAME"/></QE_ACCOUNT>
<QE_ADDRESS><xsl:value-of select="QE_ADDRESS"/></QE_ADDRESS>
<QE_PHONE><xsl:value-of select="QE_PHONE"/></QE_PHONE>
<QE_FROMROWSET/>
<QE_TOROWSET/>
<QE_SEND_SOA_BTN/>
<QE_SEND_SOS_BTN/>
<DESCRLONG></DESCRLONG>
</QE_SALES_ORDER>
</xsl:template>
Finally, you need the closing wrapper tag:
</xsl:stylesheet>
Note:
You can find more information about XSLT at the World Wide Web Consortium (W3C) web site.
Note:
A working transformation example using XSLT is provided in the PeopleTools SDK. The location of the example is <PS_HOME> \sdk\pstransform\samples\TRANSFORMTST.xml.