Subject: RE: [xsl] Newbee From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx> Date: Thu, 22 Sep 2005 11:13:55 +0100 |
From: "vijay thakre" <vijay_thakre@xxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Newbee, vijay thakre | Thread | [xsl] Templates with same name but , Kevin L. Cobb |
Re: [xsl] start-stopping xml output, Joris Gillis | Date | Re: [xsl] Strict sequential identit, Colin Paul Adams |
Month |