Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > xsl problem with test expression

Reply
Thread Tools

xsl problem with test expression

 
 
lievemario
Guest
Posts: n/a
 
      12-08-2004
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"sl="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>



 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      12-08-2004
Hi,

> version="1.0"sl="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" xmlnssl="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-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      12-09-2004
> 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-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
 
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
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C Programming 45 11-04-2008 12:39 PM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
TEST TEST TEST Gazwad Computer Support 2 09-05-2003 07:32 PM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57