Use Event Attributes in XSL Stylesheets

Overview

This scenario creates an Event-Triggered campaign with ExternalXML, customer attributes, customer preferences and event attributes. The event belongs to a valid Connect customer who is already subscribed to conv. The XSL stylesheet that consumes the event uses xsl:value-of directives to extract the event attributes.

Assumptions


  • The Gender attribute and Favorite Color preference are created in Connect.

    • Gender is a string datatype and is bounded by the values Male and Female.

    • Favorite Color is a string datatype, allows multiple values, and is not bounded.

  • The following Event Attributes are defined in the campaign.

    • Product is a string datatype.

    • Price is a number datatype.

XSL

The following XSL is similar to previously used code. The key difference is the use of the additional xsl:value-of directives to extract the event attribute data.


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Event Attributes</h2>
<p>Product: <xsl:value-of select="//Product"/></p>
<p>Price: <xsl:value-of select="//Price"/> USD</p>
 
<h2>Your CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="//ExternalXML/catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


XML

The XML is similar to previous scenarios except it contains EventAttribute elements.


<?xml version="1.0" encoding="UTF-8"?>
<kanaRoot>
<EventRequest Id="" CompanyName="default">
<Customer KeyField="EmailAddress" EmailAddress="[email protected]">
<CustomerAttribute Name="Gender">Male</CustomerAttribute>
<CustomerPreference Name="Favorite Color">
<CustomerPreferenceValue>Red</CustomerPreferenceValue >
<CustomerPreferenceValue>Blue</CustomerPreferenceValue >
</CustomerPreference>
</Customer>
<Event CampaignName="ETCamp2">
<EventAttribute Name="Product">Latest Music Collections</EventAttribute>
<EventAttribute Name="Price">300</EventAttribute>
 
<ExternalXML>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<country>USA</country>
<company>RCA</company>
<price>9.90</price>
<year>1982</year>
</cd>
</catalog>
</ExternalXML>
</Event>
</EventRequest>
</kanaRoot>


Define Campaign

Load the XSL file onto a web server. Assume the XSL file is located at the following URL:

 http://www.kana.com/connect/content/xsl/scenario5.xsl 

Create a campaign and stage the content. To stage the content for an event-triggered campaign that expects ExternalXML data, add sample data in the ExternalXML tag (including the ExternalXML tag). For example, use the following sample data to stage the content in this example:


<ExternalXML>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<country>USA</country>
<company>RCA</company>
<price>9.90</price>
<year>1982</year>
</cd>
</catalog>
</ExternalXML>


  1. Schedule the campaign.

  2. Approve the content and launch.

  3. Launch the campaign.

The Event Listener is now ready to accept events for this campaign.

Results

The CUST_ATTRIBUTES and CUST_PREFERENCES tables are updated for the customer John Smith, as follows:


The email content is:

Event Attributes

Product : Latest Music Collections

Price: 300 USD

Your CD Collection

images/brickstreetsoftware.com/ct_onlinehelp/10r56/en/Events/Event_Listener_Guide/images/collection3.jpg