xsl problem with test expression

Discussion in 'XML' started by lievemario, Dec 8, 2004.

  1. lievemario

    lievemario Guest

    I've written a small xsl file,

    but it is not working, it doesn't do the xsl:when test,

    what is wrong with it?

    The xsl-file:

    ********

    <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet
    version="1.0":xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template
    match="Faculty/select"><html><body>

    <xsl:for-each select="group">

    <xsl:variable name="type">

    <xsl:value-of select="team_type" />

    </xsl:variable><xsl:choose>

    <xsl:when test="$type='V'">

    <xsl:value-of select="name_dutch"/>

    <xsl:value-of select="team_code"/>)<br/>

    </xsl:when> </xsl:choose></xsl:for-each>
    </body></html></xsl:template></xsl:stylesheet>



    the xml-file-extraction

    *****************

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <Faculty><select><group>

    <team_code>DWIS</team_code>

    <name_dutch>Wiskunde</name_dutch>



    <team_type>V</team_type>

    </group></select></Faculty>
     
    lievemario, Dec 8, 2004
    #1
    1. Advertising

  2. lievemario

    Joris Gillis Guest

    Hi,

    > version="1.0":xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template

    --------------/
    there's a syntax error here, after correction I could not see any errors related to 'xsl:when'

    > match="Faculty/select"><html><body>
    ><xsl:for-each select="group">
    ><xsl:variable name="type">
    ><xsl:value-of select="team_type" />
    ></xsl:variable><xsl:choose>
    ><xsl:when test="$type='V'">
    ><xsl:value-of select="name_dutch"/>
    ><xsl:value-of select="team_code"/>)<br/>
    ></xsl:when> </xsl:choose></xsl:for-each>
    > </body></html></xsl:template></xsl:stylesheet>


    btw, is it really necessary to use a variable and a 'xsl:choose'?

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="Faculty/select">
    <html><body>
    <xsl:apply-templates select="group"/>
    </body></html>
    </xsl:template>

    <xsl:template match="group[team_type='V']">
    <xsl:value-of select="name_dutch"/>
    <xsl:value-of select="team_code"/>)<br/>
    </xsl:template>

    <xsl:template match="group"/>

    </xsl:stylesheet>

    regards,
    --
    Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
    Ceterum censeo XML omnibus esse utendum
     
    Joris Gillis, Dec 8, 2004
    #2
    1. Advertising

  3. lievemario

    Joris Gillis Guest

    > I've written a small xsl file,
    >
    > but it is not working, it doesn't do the xsl:when test,
    > the xml-file-extraction
    >
    > *****************
    >
    > <?xml version="1.0" encoding="ISO-8859-1"?>
    >
    > <Faculty><select><group>
    >
    > <team_code>DWIS</team_code>
    >
    > <name_dutch>Wiskunde</name_dutch>
    >
    >
    >
    > <team_type>V</team_type>
    >
    > </group></select></Faculty>
    >

    If the above is only a sample, it is most likely that whitespaces are spoiling the fun in the real XML.
    Try using <xsl:when test="normalize-space($type)='V'"/>

    regards,
    --
    Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
    Ceterum censeo XML omnibus esse utendum
     
    Joris Gillis, Dec 9, 2004
    #3
    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. Kevin Flood
    Replies:
    0
    Views:
    1,023
    Kevin Flood
    Sep 8, 2004
  2. Kevin Flood
    Replies:
    1
    Views:
    2,741
    Kevin Flood
    Sep 13, 2004
  3. Klaus Friese
    Replies:
    0
    Views:
    469
    Klaus Friese
    Nov 22, 2004
  4. Replies:
    1
    Views:
    3,613
    A. Bolmarcich
    May 27, 2005
  5. Skybuck Flying

    Call oddities: &Test() vs &Test vs Test

    Skybuck Flying, Oct 4, 2009, in forum: C Programming
    Replies:
    1
    Views:
    707
    Skybuck Flying
    Oct 4, 2009
Loading...

Share This Page