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

Discussion in 'XML' started by will, Sep 17, 2003.

  1. will

    will Guest

    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>
     
    will, Sep 17, 2003
    #1
    1. Advertising

  2. will

    Xavier Franc Guest

    Re: choosing between an attribute in the root node - simple quickq.

    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: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>
     
    Xavier Franc, Sep 17, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,670
  2. CB
    Replies:
    1
    Views:
    614
    Johannes Koch
    Oct 2, 2003
  3. Tjerk Wolterink
    Replies:
    2
    Views:
    1,521
    Dimitre Novatchev
    Aug 24, 2006
  4. Replies:
    1
    Views:
    588
    Martin Honnen
    May 8, 2007
  5. Stefan_W
    Replies:
    1
    Views:
    8,389
    Stefan_W
    Nov 5, 2008
Loading...

Share This Page