choosing between an attribute in the root node - simple quick q.

W

will

why doesnt this work? Im basically trying to get the value of the root
node attribute the 'Result' attr. Which can be one of 3 things. OK,
ERROR or INVALID, and then choosing between the 3 and outputting
different stuff. It always prints out "OtherwiseHasBeenSelected"
suggesting it doesnt test true on any of my choices :

xsl:
<?xml version='1.0' encoding='iso-8859-1'?>
<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:eek:utput method='html' version='1.0' encoding='iso-8859-1'
indent='no'/>

<xsl:template match="/">
<html>
<head>
<title>
Car Park Availability Page
</title>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"
bgcolor="#FFFFFF">
<xsl:choose>
<xsl:when test="API_Reply[@Result]='OK'">
<center>
<xsl:apply-templates select="API_Reply/CarPark"/>
</center>
</xsl:when>
<xsl:when test="API_Reply[@Result]='ERROR' ">
An error has occured: <xsl:value-of
select="API_Reply/Error/ErrorMessage"/>
</xsl:when>
<xsl:eek:therwise>
<center>
OtherwiseHasBeenSelected <xsl:apply-templates
select="API_Reply/CarPark"/>
</center>
</xsl:eek:therwise>
</xsl:choose>
</body>
</html>
</xsl:template>

xml:
<API_Reply System="ABC" Version="1.0" Product="CarPark" Customer="A"
Session="000014653" RequestCode="1"
Result="ERROR"><Error><ErrorMessage>Not available try a hotel with
parking</ErrorMessage></Error></API_Reply>
 
X

Xavier Franc

probably you should write
API_Reply/@Result = 'OK'
intead of API_Reply[@Result]='OK'

you were testing an element API_Reply having
a string value 'OK', and an attribute @Result with any value
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top