Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XLS Conditional Choice

Status
Not open for further replies.

mych

Programmer
May 20, 2004
248
GB
Hi... New to XML

Creating a sort of Service dashboard...

My XML Structure is
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?> 
	<!--  Edited by XMLSpy® --> 
	<service_data>
		<service> 
	<service_name>Outlook</service_name> 
			<data_centre>SDC01</data_centre>
			<status>3</status> 
			<details></details> 
			<timeofincident></timeofincident>
		</service>
		<service> 
			<service_name>Internet</service_name> 
			<data_centre>SDC01</data_centre>
			<status>1</status> 
			<details>Proxy Server Fault</details> 
			<timeofincident>11:03</timeofincident>
		</service>
	</service_data>

and my XLS is...
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?> 
<!--  Edited by XMLSpy® --> 
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:template match="/">
	<html>
		<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
			<div style="background-color:orange;color:black;padding:4px">SERVICES</div>
			<xsl:for-each select="service_data/service">
			<xsl:sort select="service_name"/>
				<xsl:choose>
					<xls:when test="status &gt; 2">
						<div style="background-color:green;color:white;padding:4px">
							<span style="font-weight:bold">
								<xsl:value-of select="service_name" /> 
							</span>
						</div>
					</xls:when>
					<xls:when test="status &gt; 1">
						<div style="background-color:orange;color:black;padding:4px">
							<span style="font-weight:bold">
								<xsl:value-of select="service_name" /> 
							</span>
						</div>
					</xls:when>
					<xls:otherwise>
						<div style="background-color:red;color:white;padding:4px">
							<span style="font-weight:bold">
								<xsl:value-of select="service_name" /> 
							</span>
						</div>
						<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
							<xsl:value-of select="details" /> 
								<span style="font-style:italic">
									(time of incident  
									<xsl:value-of select="timeofincident" /> 
									) 
								</span>
						</div>
					</xls:otherwise>
				</xls:choose>
			</xsl:for-each>
	  </body>
	</html>
</xsl:template>
</xsl:stylesheet>

Unfortunately I'm getting an error
Code:
The XML page cannot be displayed 
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. 


--------------------------------------------------------------------------------

Reference to undeclared namespace prefix: 'xls'. Error processing resource 'file://irf00307/4974974$/test.xsl'. Line 11, P...

     <xls:when test="status &gt; 2">

when I try to view the data.

I can't figure out where I have gone wrong.... I did have <status> set as green, amber, red and tried xls:when test="status = 'green'"> but got similar errors.

Any help appreciated.


I've not failed! Just found 100 ways that don't work...yet!
 
You have typos in the block xsl:choose. [tt][red]xls:[/red][/tt] should be read [tt]xsl:[/tt].
 
I must be dyslexic.... xls should be xsl...

It even said that in the error.... hanging head in shame

I've not failed! Just found 100 ways that don't work...yet!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top