Siebel Interactive Selling Transact Server Interface Reference > Integrating the Order Management System > Using Style Sheets >

The Sample XSLT Style Sheet


This section describes each section of code from the sample XSLT style sheet (olcp2cXML.xsl).

The following lines of code instantiate the document as an XSLT style sheet.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/ Transform" version="1.0">

If the XML output needs to be presented for human reading, the following line indents the XML content with new lines.

<xsl:output indent="yes"/>

cXML defines selected parameters that must be passed as part of the document. These parameters are constructed outside of the XML style sheet and then passed to the XSLT processor. The following lines extract the values that are passed for those parameters from the calling client and inserts them at appropriate places in the document as defined by the cXML DTD. For more detailed information about cXML and its DTD, refer to the documentation at http://www.cXML.org.

<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 following line searches for the node named "SiebelLineItem" and applies the rules defined by this style sheet to this node.

<xsl:template match="SiebelLineItem">

Optional Code

At this point, you can include the following optional line of code.

<xsl:attribute name="version"><xsl:value-of select="$version"/ ></xsl:attribute>

This line specifies the version of the cXML protocol. A validating XML parser could also determine the version attribute from the referenced DTD. However, all cXML documents should include the version explicitly to assist applications using nonvalidating parsers.

<xsl:attribute name="xml:lang"><xsl:value-of select="$locale"/ ></xsl:attribute>

This line specifies the locale used for all free text sent within this document. The receiver should reply or display information in the same or a similar locale. For example, a client specifying xml:lang="en-UK" in a request might receive "en" data in return.

<xsl:attribute name="payloadID"><xsl:value-of select="$payloadid"/></xsl:attribute>

This line specifies a unique number with respect to space and time, used for logging purposes to identify documents that might have been lost or had problems. This value should not change for retry attempts. The recommended implementation is datetime.process id.random number@hostname.

<xsl:attribute name="timestamp"><xsl:value-of select="$timestamp"/></xsl:attribute>

This line specifies the date and time the message was sent, in ISO 8601 format. This value should not change for retry attempts. The format is YYYY-MM-DDThh:mm:ss-hh:mm (for example, 1997-07-16T19:20:30+01:00). <xsl:param name="payloadid"/>

The following line instructs the XSLT processor to look for the node "User" in the input document and retrieve the value of its attribute named "order_id," and bind the value to a variable named "order_id." The variable "order_id" can be used many times later in the style sheet to insert the order id into the document.

<xsl:variable name="order_id" select="./User/@order_id"/ >

At this point, the values needed to construct the header defined by cXML have been obtained from the calling client and the input document. The following lines construct the cXML header portion with the obtained values.

<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>

The cXML header is followed by the OrderRequest node. The OrderRequest contains OrderRequestHeader and one or more ItemOut nodes.

<OrderRequest>
<OrderRequestHeader>
<xsl:attribute name="type">new</xsl:attribute>
<xsl:attribute name="orderID"><xsl:value-of select="$order_id"/></xsl:attribute>

cXML defines the total node to contain the total price of the items being ordered as well as the currency. The following lines look for any node named Total in the input document. If more than one are returned, it selects the first one and extracts the price and the currency from it. If no nodes named Total are found in the document, it inserts a default Total node in the output document with the price being 0 and the currency being "USDollars."

<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>

The following lines insert the shipping and billing addresses into the output cXML document.

<xsl:apply-templates select="./ShippingAddress"/>
<xsl:apply-templates select="./BillingAddress"/>

The following lines insert some Siebel-specific data as extrinsic values that is needed in order to translate the document from cXML back into Siebel XML format.

<Extrinsic>
<xsl:attribute name="name">siebel_id</ xsl:attribute>
<xsl:value-of select="./@siebel_id"/>
</Extrinsic>
<Extrinsic>
<xsl:attribute name="name">date_created</ xsl:attribute>
<xsl:value-of select="./@created_on"/>
</Extrinsic>
<Extrinsic>
<xsl:attribute name="name">id</xsl:attribute>
<xsl:value-of select="./@id"/>
</Extrinsic>
</OrderRequestHeader>

Templates

At this point, use the templates below to perform the following actions.

This template searches for nodes named Item in the input document, and starts constructing ItemOut nodes as defined by the cXML DTD to be inserted as part of the output document.

<xsl:apply-templates select=".//Item">
<xsl:with-param name="itemUser" select="./ User"/>
</xsl:apply-templates>


</OrderRequest>

</cXML>

</xsl:template>

This template defines rules for the XSLT processor to use to search for any node named "ShippingAddress" in the input document and inserts its values into the output document in the format required by cXML.

<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>

This template defines rules for constructing and inserting item information from the input document into the output document. The ItemOut as defined by cXML consists of nodes that contain information about the price of the item (including the currency), the quantity being ordered, the item line number, the part number of the item, and so on. However, Siebel's XML input document contains more information that may not be needed by cXML-compliant applications, but is very necessary in order to reconstruct the Siebel XML document given to the cXML document. For this reason, any Siebel-specific information is saved as Extrinsic values so that it can be used later on (for example, to reconstruct the original Siebel XML document). One example would be Configuration data that may not be used by cXML but is necessary for use in Siebel Transact applications.

<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>
<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>

This line is the closing tag for the style sheet.

</xsl:stylesheet>


 Siebel Interactive Selling Transact Server Interface Reference 
 Published: 18 April 2003