See
http://www.dpawson.co.uk/xsl/sect2/N5536.html
especially number 3.
Joe
From: "vijay thakre" <vijay_thakre(_at_)hotmail(_dot_)com>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Newbee
Date: Thu, 22 Sep 2005 15:18:56 +0530
Hello
I am very new to XML and XSL. I am using .NET2003 for Xslt tranformation to
create a text file.
My Xml looks like this.
<InvoiceFile xmlns="http://tempuri.org/InvoiceFile.xsd">
<Invoice>
<CustomerCode>1234567</CustomerCode>
<Item>
<ItemNumber>10000</ItemNumber>
<Description>Item one </Description>
<Quantity>4</Quantity>
<UnitPrice>100</UnitPrice>
<Amount>500</Amount>
</Item>
<Item>
<ItemNumber>20000</ItemNumber>
<Description>Item two </Description>
<Quantity>3</Quantity>
<UnitPrice>200</UnitPrice>
<Amount>900</Amount>
</Item>
<RowSummary>
<Rows>2</Rows>
<TotalRowAmount>1400</TotalRowAmount>
</RowSummary>
<Summary>
<TotalAmount>1400</TotalAmount>
<Currency>SEK</Currency>
</Summary>
</Invoice>
<Total>
<TotalInvoices>1</TotalInvoices>
<TotalAmount>1400</TotalAmount>
</Total>
</InvoiceFile>
And my xslt is
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="delimiter">';'</xsl:variable>
<xsl:template match="/">
<xsl:text>10';'STARTINVOICEFILE';'</xsl:text>
<xsl:apply-templates select="/InvoiceFile/Invoice"/>
<xsl:text>99';'ENDINVOICEFILE';'</xsl:text>
</xsl:template>
<xsl:template match="Invoice">
<xsl:value-of select="CustomerCode"/>
</xsl:template>
</xsl:stylesheet>
My output looks like
10';'STARTCUSTOMERFILE';'99';'ENDCUSTOMERFILE';'
Where is all other information.
And if I change root template to
<xsl:template match="InvoiceFile">
<xsl:text>10';'STARTCUSTOMERFILE';'</xsl:text>
<xsl:apply-templates select="Invoice"/>
<xsl:text>99';'ENDCUSTOMERFILE';'</xsl:text>
</xsl:template>
I get(Text of all nodes in one line)
123456710000Item one 410050020000Item two 3200900214001234,9SEK11400
Whereas I expect only Customer code to be printed like
10';'STARTCUSTOMERFILE'1234567;'99';'ENDCUSTOMERFILE';'
Please help. I know I am doing something wrong in the basics. Cannot figur
out.
Thanks in advance.
P.S. my InvoiceFile.xsd has LOT more elements then they appear in XML
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--