Tuesday, 17 February 2015

xslt apply-templates removes everything but values passed



I am using XSLT templates to generate emails that will go out to call center. Issue I am having - transformation in apply-templates eliminates everything but the values. Chances are this is something trivial that I am failing to see.


XSLT:



<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/*">
We have just received the following Legal Services Call me back form. Please contact them as soon as possible..<br /><br /><br />
<table border="0px">
<tr>
<td>Product</td>
<td width="10px">:</td>
<td>
<xsl:value-of select="ShortProductName"/>
</td>
</tr>
<xsl:if test="HasSingleOrCouple='true'">
<tr>
<td>Single Or Couple</td>
<td width="10px">:</td>
<td>
<xsl:value-of select="SingleOrCouple"/>
</td>
</tr>
</xsl:if>
<tr>
<td>Title</td>
<td width="10px">:</td>
<td>
<xsl:value-of select="Title"/>
</td>
</tr>
<tr>
<td>Firstname</td>
<td width="10px">:</td>
<td>
<xsl:value-of select="Firstname"/>
</td>
</tr>
<tr>
<td>Surname</td>
<td width="10px">:</td>
<td>
<xsl:value-of select="Surname"/>
</td>
</tr>
<tr>
<td>Telephone</td>
<td width="10px">:</td>
<td>
<xsl:value-of select="Phone"/>
</td>
</tr>
<xsl:apply-templates select="Products/ProductsItem"></xsl:apply-templates>
</table>
</xsl:template>

<xsl:template name="Products">
<tr>
<td>
Product
</td>
<td width="10px">:</td>
<td>
<xsl:value-of select="ProductType"/>
</td>
</tr>
<xsl:apply-templates select="PriceLines/PriceLinesItem" />
</xsl:template>

<xsl:template match="PriceLine">
<tr>
<td>
<xsl:value-of select="Key"/>
</td>
<td width="10px">:</td>
<td>
<xsl:value-of select="format-number(Value, '#,##0.00')"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>


XML:



<?xml version="1.0" encoding="utf-8" ?>
<object>
<HasSingleOrCouple>false</HasSingleOrCouple>
<Title>Mrs</Title>
<Firstname>M</Firstname>
<Surname>Vaitke</Surname>
<Phone>07809263588</Phone>
<Products>
<ProductsItem>
<ProductType>Sale quotation</ProductType>
<PriceLines>
<PriceLinesItem>
<Key>Legal fee</Key>
<Value>540.8300</Value>
</PriceLinesItem>
<PriceLinesItem>
<Key>legal discount</Key>
<Value>0</Value>
</PriceLinesItem>
<PriceLinesItem>
<Key>Leasehold fee</Key>
<Value>125.0000</Value>
</PriceLinesItem>
<PriceLinesItem>
<Key>Total legal fees (excluding VAT)</Key>
<Value>665.8300</Value>
</PriceLinesItem>
<PriceLinesItem>
<Key>Anti money laundering (AML) checks</Key>
<Value>6.0000</Value>
</PriceLinesItem>
<PriceLinesItem>
<Key>Lender liaison fee</Key>
<Value>0</Value>
</PriceLinesItem>
<PriceLinesItem>
<Key>Bank transfer fee</Key>
<Value>30.0000</Value>
</PriceLinesItem>
<PriceLinesItem>
<Key>Office copies</Key>
<Value>12.0000</Value>
</PriceLinesItem>
<PriceLinesItem>
<Key>Total other fees (excluding VAT)</Key>
<Value>48.0000</Value>
</PriceLinesItem>
<PriceLinesItem>
<Key>Total VAT</Key>
<Value>142.76600</Value>
</PriceLinesItem>
<PriceLinesItem>
<Key>Total (including VAT)</Key>
<Value>856.59600</Value>
</PriceLinesItem>
</PriceLines>
</ProductsItem>
</Products>
<IsCouple>false</IsCouple>
<Product>Conveyancing Service</Product>
<ShortProductName>Conveyancing</ShortProductName>
<AdditionalPriceLines>
<AdditionalPriceLinesItem>
<Key>Total</Key>
<Value>856.59600</Value>
</AdditionalPriceLinesItem>
</AdditionalPriceLines>
</object>


Result I am getting:



<?xml version="1.0" encoding="UTF-8"?>
We have just received the following Legal Services Call me back form. Please contact them as soon as possible..<br/>
<br/>
<br/>
<table border="0px">
<tr>
<td>Product</td>
<td width="10px">:</td>
<td>Conveyancing</td>
</tr>
<tr>
<td>Title</td>
<td width="10px">:</td>
<td>Mrs</td>
</tr>
<tr>
<td>Firstname</td>
<td width="10px">:</td>
<td>M</td>
</tr>
<tr>
<td>Surname</td>
<td width="10px">:</td>
<td>Vaitke</td>
</tr>
<tr>
<td>Telephone</td>
<td width="10px">:</td>
<td>07809263588</td>
</tr>
Sale quotation


Legal fee
540.8300


legal discount
0


Leasehold fee
125.0000


Total legal fees (excluding VAT)
665.8300


Anti money laundering (AML) checks
6.0000


Lender liaison fee
0


Bank transfer fee
30.0000


Office copies
12.0000


Total other fees (excluding VAT)
48.0000


Total VAT
142.76600


Total (including VAT)
856.59600


</table>


How can I keep the html tags?


No comments:

Post a Comment