xsl problem with test expression

lievemario

Usenet Archive
Joined
Nov 8, 2004
Messages
10
Reaction score
0
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>
 

Joris Gillis

Usenet Archive
Joined
Sep 28, 2004
Messages
355
Reaction score
0
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

Usenet Archive
Joined
Sep 28, 2004
Messages
355
Reaction score
0
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,
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top