Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > choosing between an attribute in the root node - simple quick q.

Reply
Thread Tools

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

 
 
will
Guest
Posts: n/a
 
      09-17-2003
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'
xmlnssl='http://www.w3.org/1999/XSL/Transform'>
<xslutput 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>
<xsltherwise>
<center>
OtherwiseHasBeenSelected <xsl:apply-templates
select="API_Reply/CarPark"/>
</center>
</xsltherwise>
</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>
 
Reply With Quote
 
 
 
 
Xavier Franc
Guest
Posts: n/a
 
      09-17-2003
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


will wrote:
> 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'
> xmlnssl='http://www.w3.org/1999/XSL/Transform'>
> <xslutput 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>
> <xsltherwise>
> <center>
> OtherwiseHasBeenSelected <xsl:apply-templates
> select="API_Reply/CarPark"/>
> </center>
> </xsltherwise>
> </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>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[XSLT] Select node by attribute with value from an attribute of its self Stefan_W XML 1 11-05-2008 10:50 AM
Problem updating an attribute that appears in both root node and child node! Tedros.G@googlemail.com XML 1 05-08-2007 11:32 AM
xsl variable $node/text() but $node can non-node-set help! Tjerk Wolterink XML 2 08-24-2006 03:28 AM
How to set the node indent property between the parent node and the leaf node viveknatani@gmail.com ASP .Net 0 02-13-2006 07:11 PM
XSL HOWDOI use attribute of current node to select a different node? CB XML 1 10-02-2003 02:37 PM



Advertisments