Bookshelf Home | Contents | Index | Search | PDF |
Siebel Interactive Selling Transact Server Interface Reference > Additional Code >
XSLT Style Sheet Example
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes"/>
<!-- ******************************************
get all the parameters that are passed from outside
*********************************************** -->
<xsl:param name="payloadid"/>
<xsl:param name="timestamp"/>
<xsl:param name="version" select="'1.0'"/>
<xsl:param name="locale" select="'en-US'"/>
<xsl:param name="from_domain"/>
<xsl:param name="to_domain"/>
<xsl:param name="sender_domain"/>
<xsl:param name="from_identity"/>
<xsl:param name="to_identity"/>
<xsl:param name="sender_identity"/>
<xsl:param name="sender_secret"/>
<xsl:param name="user_agent"/>
<!-- ******************************************
the template that matches the root item
*********************************************** -->
<xsl:template match="SiebelQuote">
<cXML>
<!-- *******************************************
setup the attributes for the cXML element
************************************************ -->
<xsl:attribute name="version"><xsl:value-of select="$version"/ ></xsl:attribute>
<xsl:attribute name="payloadID"><xsl:value-of select="$payloadid"/></xsl:attribute>
<xsl:attribute name="timestamp"><xsl:value-of select="$timestamp"/></xsl:attribute>
<xsl:attribute name="xml:lang"><xsl:value-of select="$locale"/ ></xsl:attribute>
<!-- *******************************************
setup the values for the variables
************************************************ -->
<xsl:variable name="order_id" select="./User/@order_id"/>
<!-- *******************************************
setup the cXML header
************************************************ -->
<Header>
<From>
<Credential>
<xsl:attribute name="domain"><xsl:value-of select="$from_domain"/></xsl:attribute>
<Identity>
<xsl:value-of select="$from_identity"/>
</Identity>
</Credential>
</From>
<To>
<Credential>
<xsl:attribute name="domain"><xsl:value-of select="$to_domain"/></xsl:attribute>
<Identity>
<xsl:value-of select="$to_identity"/>
</Identity>
</Credential>
</To>
<Sender>
<Credential>
<xsl:attribute name="domain"><xsl:value-of select="$sender_domain"/></xsl:attribute>
<Identity>
<xsl:value-of select="$sender_identity"/>
</Identity>
<SharedSecret>
<xsl:value-of select="$sender_secret"/>
</SharedSecret>
</Credential>
<UserAgent>
<xsl:value-of select="$user_agent"/>
</UserAgent>
</Sender>
</Header>
<!-- **********************************************
setup the cXML OrderRequest (Header & ItemOut)
*************************************************** -->
<OrderRequest>
<OrderRequestHeader>
<xsl:attribute name="type">new</xsl:attribute>
<xsl:attribute name="orderID"><xsl:value-of select="$order_id"/></xsl:attribute>
<!-- **********************************************
TOTAL
*************************************************** -->
<Total>
<Money>
<xsl:choose>
<xsl:when test="./Total">
<xsl:attribute name="currency"><xsl:value-of select="./Total[position()=1]/@currency"/></xsl:attribute>
<xsl:value-of select="./Total[position()=1]"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="currency"><xsl:value-of select="'USDollars'"/></xsl:attribute>
<xsl:value-of select="0.0"/>
</xsl:otherwise>
</xsl:choose>
</Money>
</Total>
<!-- **********************************************
SHIPPING AND BILLING ADDRESSES
*************************************************** -->
<xsl:apply-templates select="Header/ShippingAddress"/>
<xsl:apply-templates select="Header/BillingAddress"/>
<!-- **********************************************
OTHER Siebel SPECIFIC DATA
*************************************************** -->
<Extrinsic>
<xsl:attribute name="name">quote_id</xsl:attribute>
<xsl:value-of select="./@quote_id"/>
</Extrinsic>
<Extrinsic>
<xsl:attribute name="name">date_created</xsl:attribute>
<xsl:value-of select="./@date_created"/>
</Extrinsic>
<xsl:apply-templates select="./Header/HeaderData"/>
<!-- **********************************************
ITEM INFORMATION
*************************************************** -->
<xsl:apply-templates select="SiebelLineItem"/>
</OrderRequestHeader>
</OrderRequest>
</cXML>
</xsl:template>
<xsl:template match="ShippingAddress">
<ShipTo>
<Address>
<Name>
<xsl:attribute name="xml:lang"><xsl:value-of select="$locale"/></xsl:attribute>
<xsl:value-of select="Name"/>
</Name>
<Street><xsl:value-of select="Street"/></Street>
<City><xsl:value-of select="City"/></City>
<State><xsl:value-of select="State"/></State>
<Country><xsl:value-of select="Country"/></Country>
<PostalCode><xsl:value-of select="PostalCode"/></PostalCode>
</Address>
</ShipTo>
</xsl:template>
<xsl:template match="BillingAddress">
<BillTo>
<Address>
<Name>
<xsl:attribute name="xml:lang"><xsl:value-of select="$locale"/></xsl:attribute>
<xsl:value-of select="Name"/>
</Name>
<Street><xsl:value-of select="Street"/></Street>
<City><xsl:value-of select="City"/></City>
<State><xsl:value-of select="State"/></State>
<Country><xsl:value-of select="Country"/></Country>
<PostalCode><xsl:value-of select="PostalCode"/></PostalCode>
</Address>
</BillTo>
</xsl:template>
<xsl:template match="HeaderData">
<Extrinsic>
<xsl:attribute name="name"><xsl:value-of select="@name"/></ xsl:attribute>
<xsl:value-of select="."/>
</Extrinsic>
</xsl:template>
<xsl:template match="SiebelLineItem">
<xsl:apply-templates select=".//Item">
<xsl:with-param name="itemUser" select="./User"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="Item">
<ItemOut>
<xsl:attribute name="quantity"><xsl:value-of select="@quantity"/></xsl:attribute>
<xsl:attribute name="lineNumber"><xsl:value-of select="../ @id"/></xsl:attribute>
<ItemID>
<SupplierPartID>
<xsl:value-of select="@part_number"/>
</SupplierPartID>
</ItemID>
<ItemDetail>
<UnitPrice>
<Money>
<xsl:choose>
<xsl:when test="./Price">
<xsl:attribute name="currency"><xsl:value-of select="./Price[position()=1]/@currency"/></xsl:attribute>
<xsl:value-of select="./Price[position()=1]"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="currency"><xsl:value-of select="'USDollars'"/></xsl:attribute>
<xsl:value-of select="0.0"/>
</xsl:otherwise>
</xsl:choose>
</Money>
</UnitPrice>
<UnitOfMeasure></UnitOfMeasure>
<Description>
<xsl:value-of select="@description"/>
</Description>
<xsl:if test="$itemUser">
<Extrinsic>
<xsl:attribute name="name">userID</xsl:attribute>
<xsl:value-of select="$itemUser/@user_id"/>
</Extrinsic>
<Extrinsic>
<xsl:attribute name="name">accountID</xsl:attribute>
<xsl:value-of select="$itemUser/@account_id"/>
</Extrinsic>
<Extrinsic>
<xsl:attribute name="name">sessionID</xsl:attribute>
<xsl:value-of select="$itemUser/@session_id"/>
</Extrinsic>
</xsl:if>
<Extrinsic>
<xsl:choose>
<xsl:when test="./Price">
<xsl:attribute name="name">parentID</ xsl:attribute>
<xsl:value-of select="../@part_number"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="name">parentID</ xsl:attribute>
<xsl:value-of select="0"/>
</xsl:otherwise>
</xsl:choose>
</Extrinsic>
<xsl:apply-templates select="./ConfigData"/>
</ItemDetail>
</ItemOut>
</xsl:template>
<xsl:template match="ConfigData">
<Extrinsic>
<xsl:attribute name="name"><xsl:value-of select="concat('cfg_', @name)"/></xsl:attribute>
<xsl:value-of select="."/>
</Extrinsic>
</xsl:template>
</xsl:stylesheet>
Bookshelf Home | Contents | Index | Search | PDF |
Siebel Interactive Selling Transact Server Interface Reference Published: 18 April 2003 |