473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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:output 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:otherwise>
<center>
OtherwiseHasBeenSelected <xsl:apply-templates
select="API_Reply/CarPark"/>
</center>
</xsl:otherwise>
</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>
Jul 20 '05 #1
1 1583
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'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output 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:otherwise>
<center>
OtherwiseHasBeenSelected <xsl:apply-templates
select="API_Reply/CarPark"/>
</center>
</xsl:otherwise>
</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>


Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
4
by: Lénaïc Huard | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, I've some namespace problems when defining default values for attributes. My problem seems to come from the fact that the attributes are...
1
by: davisjoseph | last post by:
Hi, I'm using Xerces C++ API for XML operations. I need to remove the XML namespace attribute from this type of XML doc, <?xml version="1.0" encoding="UTF-8"?> <root...
2
by: Greg | last post by:
Hi. I have a rather large xml document (object) that can have one or more nodes with a certain attribute throughout (at ANY depth, not at the same level necessarily). I need to find this...
4
by: Karine Bosch | last post by:
Hi, My xml document uses different namespaces: <x:root xmlns:x="x:ns:meta/"> <element1 xmlns:adam="http://ns.alfaprint.be/"> </root> This gives problems when using an XPath query. I...
7
by: Simon Hart | last post by:
Hi, I have a requirement to remove the xmlns from the DOM in order to pass over to MS CRM 3.0 Fetch method.It seems the fetch method blows up if there is a xmlns present!?! The reason I have a...
5
by: patrin | last post by:
Hi All, given the source document: <?xml version="1.0" encoding="UTF-8"?> <root> <child> <test id="1" name="first child"/> </child> <child>
1
by: Tedros.G | last post by:
Hi I have an attribute the appears in both the root node and child node for example, below the attribute VERSION appears in the rood node (PRODMSG ) and a child node (OPERATION ) ================...
7
by: Ebenezer | last post by:
Hello! Let's suppose we have an XML with some nested NODE nodes: <root attr="first"> <node id="1" attr="mike"> <node id="2" /> <node id="3" attr="dave" /> </node> <node id="4">
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.