i have an xml file
<?xml version="1.0" encoding="utf-16"?>
<?xml-stylesheet type="text/xsl"?>
<Order OrderNo="582" Orderdate="7/16/2003 3:34:42 PM" Shipdate="7/18/2003 3:34:42 PM">
<Products TotalCost="$20.00">
<Product ProductId="438" ProdName="Men-T-Shirt, Yacht, weiß, L" ModelName="MO-0035-MTSYA-W
-L" Quantity="1" UnitCost="20.00" SubTotal="20.00" />
<Product ProductId="213" ProdName="Men-T-Shirt" ModelName="MO-0035-MTSYA-W
-L" Quantity="1" UnitCost="20.00" SubTotal="20.00" />
<Product ProductId="123" ProdName="Men-T-Shirt, Yacht, weiß, L" ModelName="MO-0011-MTSYA-W
-L" Quantity="1" UnitCost="20.00" SubTotal="20.00" />
<Product ProductId="567" ProdName="Men-T-Shirt, Yacht, weiß, L" ModelName="MO-0011-MTSYA-W
-L" Quantity="1" UnitCost="20.00" SubTotal="20.00" />
<Product ProductId="458" ProdName="Men-T-Shirt, Yacht, weiß, L" ModelName="MO-0011-MTSYA-W
-L" Quantity="1" UnitCost="20.00" SubTotal="20.00" />
<Product ProductId="428" ProdName="Men-T-Shirt, Yacht, weiß, L" ModelName="MO-0011-MTSYA-W
-L" Quantity="1" UnitCost="20.00" SubTotal="20.00" />
<Product ProductId="456" ProdName="Men-T-Shirt, Yacht, weiß, L" ModelName="MO-00s-MTSYA-W-
L" Quantity="1" UnitCost="20.00" SubTotal="20.00" />
<Product ProductId="449" ProdName="Men-T-Shirt, Yacht, weiß, L" ModelName="MO-00sa-MTSYA-W
-L" Quantity="1" UnitCost="20.00" SubTotal="20.00" />
</Products>
<ShippingAddress Firstname="Sharath" Lastname="Neela" Street="Hubertus Str 5" ZipCode="83022" Location="Rosenheim" Country="Deutschland" />
</Order>
my xsl is:
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
<xsl:output method = "text" encoding = "ISO-8859-1" omit-xml-declaration = "yes"/>
<xsl:template match="/">
<xsl:call-template name="DefaultEmail"/>
</xsl:template>
<xsl:template name="DefaultEmail">
<xsl:call-template name="OrderDetails"/><xsl:
call-templ
ate name="ShippingAddress"/><x
sl:text>&#
10;</xsl:t
ext><xsl:t
ext> <
/xsl:text>
</xsl:template>
<xsl:template name="OrderDetails">Your Order No:<xsl:value-of select="Order/@OrderNo"/>,
Dated on <xsl:value-of select="Order/@Orderdate"/
>
<xsl:text> </xsl:text>
<xsl:text>
</xsl
:text>
</xsl:template>
<xsl:template name="ProductDetails">
<xsl:text> </xsl:text>
<xsl:text>
</xsl
:text>
SerialNo	ProductID	P
roductName
		&#
9;	Mode
l		Q
uantity	
;Price	
Subtotal
--------	---------	-
----------
		&#
9;	----
-		-
-------	
;-----	
--------
<xsl:for-each select="Order/Products/Pro
duct">
<xsl:value-of select="position()"/>
<xsl:text>		</xsl:te
xt>
<xsl:value-of select="@ProductId"/>
<xsl:text>		</xsl:te
xt>
<xsl:value-of select="@ProdName"/>
<xsl:text>		</xsl:te
xt>
<xsl:value-of select="@ModelName"/>
<xsl:text>		</xsl:te
xt>
<xsl:value-of select="@Quantity"/>
<xsl:text>		</xsl:te
xt>
<xsl:value-of select="@UnitCost"/>
<xsl:text>		</xsl:te
xt>
<xsl:value-of select="@SubTotal"/>
<xsl:text>		</xsl:te
xt><xsl:te
xt>
</xsl:text>
</xsl:for-each>
<xsl:text> </xsl:
text>
<xsl:text>Total : </xsl:text><xsl:value-of select="//Products/@TotalC
ost"/>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>
This produces the below output:
Your Order No:582, Dated on 7/16/2003 3:34:42 PM
Serial No ProductID Product Name Model Quantity Price Subtotal
1 438 Men-T-Shirt, Yacht, weiß, L MO-0035-MTSYA-W-L 1 20.00 20.00
2 213 Men-T-Shirt, Yacht, weiß, L MO-0035-MTSYA-W-L 1 20.00 20.00
3 123 Men-T-Shirt MO-0011-MTSYA-W-L 1 20.00 20.00
4 567 Men-T-Shirt, Yacht, weiß, L MO-0011-MTSYA-W-L 1 20.00 20.00
5 458 Men-T-Shirt, Yacht, weiß, L MO-0011-MTSYA-W-L 1 20.00 20.00
6 428 Men-T-Shirt, Yacht, weiß, L MO-0011-MTSYA-W-L 1 20.00 20.00
7 456 Men-T-Shirt, Yacht, weiß, L MO-00s-MTSYA-W-L 1 20.00 20.00
8 449 Men-T-Shirt, Yacht, weiß, L MO-00sa-MTSYA-W-L 1 20.00 20.00
the number of characters(string length) for the values of productname is different.
as the number characters are different,the alignment is changing.
how to keep a constant spacing for each productname.
for example for one productname the characters are 27,
for other productname characters are 10.for this product i want to fill remaining 17 characters with spaces .
so that the format is correct.
I AM TRYING TO GET THE BELOW FORMAT:
Serial No ProductID Product Name Model Quantity Price Subtotal
1 438 Men-T-Shirt, Yacht, weiß, L MO-0035-MTSYA-W-L 1 20.00 20.00
2 213 Men-T-Shirt, Yacht, weiß, L MO-0035-MTSYA-W-L 1 20.00 20.00
3 123 Men-T-Shirt,W MO-0011-MTSYA-W-L 1 20.00 20.00
4 567 Men-T-Shirt, Yacht, weiß, L MO-0011-MTSYA-W-L 1 20.00 20.00
5 458 Men-T-Shirt, Yacht, weiß, L MO-0011-MTSYA-W-L 1 20.00 20.00
6 428 Men-T-Shirt, Yacht, weiß, L MO-0011-MTSYA-W-L 1 20.00 20.00
7 456 Men-T-Shirt, Yacht, weiß, L MO-00s-MTSYA-W-L 1 20.00 20.00
8 449 Men-T-Shirt, Yacht, weiß, L MO-00sa-MTSYA-W-L 1 20.00 20.00
Hope you understood the question.
Thanks for any kind of help
vihar123