XSL delivers an unwanted bonus

G

Guest

I have an app wherein I need to transform some XML using an XSL Stylesheet.
Everything works great until the end of the template is reached.

My template is as follows:

<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/Letter/Header">
<html>
<body>
<info xml:space="preserve">
<head>
<STYLE TYPE="text/css">DIV{page-break-after: always}</STYLE>
</head>

<xsl:value-of select="Date"/>
<br />
<br />
<xsl:value-of select="FirstName"/>
<xsl:value-of select="MiddleName"/>
<xsl:value-of select="LastName"/>
<br />
<xsl:value-of select="Address1"/>
<br />
<xsl:value-of select="City"/>,
<xsl:value-of select="State"/>
<xsl:value-of select="Zip"/>
<xsl:value-of select="Country"/>
<br />
<br />
<br />
<br />
<xsl:text>Dear </xsl:text>
<xsl:value-of select="FirstName"/><xsl:text>:</xsl:text>
<br />
<br />

<table border="0">
<tr>
<td>
<xsl:text>Overpayment ID</xsl:text>
</td>
<td>
<xsl:text>Overpayment Amount</xsl:text>
</td>
<td>
<xsl:text>Reason</xsl:text>
</td>
</tr>
<xsl:for-each select="/Letter/Overpayments">
<tr>
<td style="width:20%;">
<xsl:value-of select="OverpaymentId"/>
</td>
<td style="width:25%;">
<xsl:value-of select="OverpaymentAmount"/>
</td>
<td style="width:50%;">
<xsl:value-of select="Reason"/>
</td>
</tr>
</xsl:for-each>
</table>
<br />
<xsl:text>Your friends at BCBST</xsl:text>
<DIV />
</info>
</body>
</html>
</xsl:template>

</xsl:stylesheet>

My data is as follows:
<Letter>
<Header>
<ProviderId>1</ProviderId>
<Date>10/25/2007</Date>
<FirstName>First</FirstName>
<MiddleName>Middle</MiddleName>
<LastName>Last</LastName>
<Address1>123 Main St</Address1>
<City>Chattanooga</City>
<State>TN</State>
<Zip>37343</Zip>
<Country>USA</Country>
</Header>
<Overpayments>
<OverpaymentId>1</OverpaymentId>
<OverpaymentAmount>100</OverpaymentAmount>
<Reason>Coding Error</Reason>
</Overpayments>
<Overpayments>
<OverpaymentId>2</OverpaymentId>
<OverpaymentAmount>200</OverpaymentAmount>
<Reason>Coding Error</Reason>
</Overpayments>
<Overpayments>
<OverpaymentId>3</OverpaymentId>
<OverpaymentAmount>300</OverpaymentAmount>
<Reason>Coding Error</Reason>
</Overpayments>
</Letter>

Intended output is:
10/25/2007

First Middle Last
123 Main St
Chattanooga, TN 37343 USA



Dear First:

Overpayment ID Overpayment Amount Reason
1 100 Coding Error
2 200 Coding Error
3 300 Coding Error

Your friends at BCBST


I get the output listed above when I transform the data, but the "bonus" I
mentioned comes in the form of a line reading "1 100 Coding Error 2 200
Coding Error 3 300 Coding Error" on the line below the phrase "Your friends
at BCBST". This line gets put there when the parser hits the </xsl:template>
line. Is there any cause for this to occur?

Allen
 
A

Anthony Jones

AlBruAn said:
I have an app wherein I need to transform some XML using an XSL Stylesheet.
Everything works great until the end of the template is reached.

My template is as follows:

<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/Letter/Header">
<html>
<body>
<info xml:space="preserve">
<head>
<STYLE TYPE="text/css">DIV{page-break-after: always}</STYLE>
</head>

<xsl:value-of select="Date"/>
<br />
<br />
<xsl:value-of select="FirstName"/>
<xsl:value-of select="MiddleName"/>
<xsl:value-of select="LastName"/>
<br />
<xsl:value-of select="Address1"/>
<br />
<xsl:value-of select="City"/>,
<xsl:value-of select="State"/>
<xsl:value-of select="Zip"/>
<xsl:value-of select="Country"/>
<br />
<br />
<br />
<br />
<xsl:text>Dear </xsl:text>
<xsl:value-of select="FirstName"/><xsl:text>:</xsl:text>
<br />
<br />

<table border="0">
<tr>
<td>
<xsl:text>Overpayment ID</xsl:text>
</td>
<td>
<xsl:text>Overpayment Amount</xsl:text>
</td>
<td>
<xsl:text>Reason</xsl:text>
</td>
</tr>
<xsl:for-each select="/Letter/Overpayments">
<tr>
<td style="width:20%;">
<xsl:value-of select="OverpaymentId"/>
</td>
<td style="width:25%;">
<xsl:value-of select="OverpaymentAmount"/>
</td>
<td style="width:50%;">
<xsl:value-of select="Reason"/>
</td>
</tr>
</xsl:for-each>
</table>
<br />
<xsl:text>Your friends at BCBST</xsl:text>
<DIV />
</info>
</body>
</html>
</xsl:template>

</xsl:stylesheet>

My data is as follows:
<Letter>
<Header>
<ProviderId>1</ProviderId>
<Date>10/25/2007</Date>
<FirstName>First</FirstName>
<MiddleName>Middle</MiddleName>
<LastName>Last</LastName>
<Address1>123 Main St</Address1>
<City>Chattanooga</City>
<State>TN</State>
<Zip>37343</Zip>
<Country>USA</Country>
</Header>
<Overpayments>
<OverpaymentId>1</OverpaymentId>
<OverpaymentAmount>100</OverpaymentAmount>
<Reason>Coding Error</Reason>
</Overpayments>
<Overpayments>
<OverpaymentId>2</OverpaymentId>
<OverpaymentAmount>200</OverpaymentAmount>
<Reason>Coding Error</Reason>
</Overpayments>
<Overpayments>
<OverpaymentId>3</OverpaymentId>
<OverpaymentAmount>300</OverpaymentAmount>
<Reason>Coding Error</Reason>
</Overpayments>
</Letter>

Intended output is:
10/25/2007

First Middle Last
123 Main St
Chattanooga, TN 37343 USA



Dear First:

Overpayment ID Overpayment Amount Reason
1 100 Coding Error
2 200 Coding Error
3 300 Coding Error

Your friends at BCBST


I get the output listed above when I transform the data, but the "bonus" I
mentioned comes in the form of a line reading "1 100 Coding Error 2 200
Coding Error 3 300 Coding Error" on the line below the phrase "Your friends
at BCBST". This line gets put there when the parser hits the
line. Is there any cause for this to occur?

This question would have been better placed in the XSL group but I'll answer
it here.

You've matched /letter/header. Your template does it stuff. Then the
processor continues and finds a set of overpayment nodes which not matching
any template gets the default treament of the text content being output.

The top template should match just the root node in the document (ie
/letter) that way that template controls all the processing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top