I consider myself still a newbie to xslt as all I did so far is basic opertion using templateobject and variables and get an html output. I am into my learning step for complex computation. I need help from the experts in the forum to help resolve one of my situation.
I am building template for email. Below is my xslt that I want to transform. Additional to this I want to pass another xml to it for the xslt to loop through and get the attribute value to assign in the respective places in the html.
Below code doesn't work, just an example to demonstrate on what I intended to do.
XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:templateObject="urn:data">
<xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:variable name="products" />
<xsl:variable name="doc" select="document($products)"/>
<xsl:template match="/body">
<html>
<body bgcolor="#E5E5E5" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0">
<table style="width:100%;" class="orderItems">
<xsl:for-each select="$doc">
<tbody>
<tr>
<td class="itemThumbnail" style="width:80px; height:70px; padding-top:20px;">
<img src="ref" alt="" />
</td>
<td style="padding-top:20px; font-family:Arial, Verdana, Helvetica, sans-serif; font-size: 16px; line-height: 20px; color:#4c4c4c;">
<xsl:value-of select="$ProductName" /><br />
Quantity: 1
</td>
<td style="text-align:right; font-family:Arial, Verdana, Helvetica, sans-serif; font-size: 16px; line-height: 20px; color:#4c4c4c;">
Price: <strong style="font-size:20px; color:#b9277e;">
<xsl:value-of select="$Amount" />
</strong>
</td>
</tr>
</tbody>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XML
<Root>
<item ProductName="abc" Amount="$20" />
<item ProductName="xyz" Amount="$50" />
</Root>
I tried to assign the xml as string to the xslt variable and tried to create a document with in XSLT using document() function but still not able to loop through the element and attributes.
Appreciate any help on this
Couple of other queries: - Can I nest xsl:template by assigning multiple xml to xslt through c# by declaring the namespace on the header? - Can conversion be possible in xslt from string to xml?