[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Using style sheet to display XML data

Subject: Using style sheet to display XML data
From: Jitt_Joynoosaeng@xxxxxxxxxxx
Date: Fri, 26 Oct 2001 10:05:54 -0500
style sheet to display xml
Hi,

I'm having problems displaying my XML.  I have a style sheet that 
should display the XML in this form:
No Test Results Found for BOL Number: 123  234

BOL Number	Bundle Number
123		111
		222
		333
234		111

The XML data I'm using is this:
<errors>
	<error>
		<bundle>111</bundle>
		<bol>123</bol>
	</error>
	<error>
		<bundle>222</bundle>
		<bol>123</bol>
	</error>
	<error>
		<bundle>333</bundle>
		<bol>123</bol>
	</error>
	<error>
		<bundle>111</bundle>
		<bol>234</bol>
	</error>
</errors>

My style sheet looks like this:
<table>
	<tr>
	<td>No Test Results Found for Bill of Lading Number:</td>
		<xsl:for-each select="errors/error"> 
		<xsl:variable name="bolvalue" select="bol"/>
		<xsl:choose>

			<xsl:when test="count(following::bol[.=$bolvalue]) !=0">
				<td><xsl:value-of select="bol"</td>	
			</xsl:when>
		
			<xsl:when test="count(preceding::bol[.=$bolvalue]) != 0">
				<td></td>
			</xsl:when>
					
			<xsl:otherwise>
				<td><xsl:value-of select="bol"/></td>	
			</xsl:otherwise>
		</xsl:choose>
		</xsl:for-each> 
	</tr>
</table>

<table>
	<tr>
	<th>BOL Number</th>
	<th>Bundle Number</th>
	</tr>
	<xsl:for-each select="errors/error">
	<xsl:variable name="value" select="bol"/>
		<xsl:choose>
		<xsl:when test="count(following::bol[.=$value]) !=0">
		<tr>
			<td><xsl:value-of select="bol"/></td>
			<td><xsl:value-of select="bundle"/></td>
		</tr>
		</xsl:when>
									
		<xsl:when test="count(preceding::bol[.=$value]) != 0">
		<tr>
			<td></td>
			<td><xsl:value-of select="bundle"/></td>
		</tr>
		</xsl:when>
							
		<xsl:otherwise>
		<!-- Display all other components with single occurance -->
		<tr>
			<td><xsl:value-of select="bol"/></td>
			<td><xsl:value-of select="bundle"/></td>
		</tr>
		</xsl:otherwise>							
		</xsl:choose>
		</xsl:for-each>
</table>
		
		
If there are different BOL numbers, then display that after the "No 
Test Results Found for BOL Number:" statement.  Also, if the BOL number 
is the same number, I don't want the BOL number to display beneath the 
first BOL in the table.  If it is a different BOL, then have it 
display.  

I have ran two different tests with different XML data.  The first 
example seems to come out fine. But there is something funny going on 
with the 2nd example.

EXAMPLE1:
No Test Results Found for BOL Number: 123 

BOL Number	Bundle Number
123		111
		222
	
EXAMPLE2:
No Test Results Found for BOL Number: 123  123

BOL Number	Bundle Number
123		111
123		222
		333


Thanks for any help anyone can provide...

Jitt


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.