This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Using style sheet to display XML data


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]