Cześć wam,
Mam taki problem z XSL, otóż chcę zrobić tak żeby lista numerowana wyświetlała wpisy tak, że wpisy mają być na niebiesko, a co drugi np na zielono...
Coś tego typu:
Astrid Lindgren1.
Bracia Lwie Serce2.
Braciszek i Karlsoon z dachu3.
Dzieci z Bullerbyn4.
Dzieci z z ulicy Awanturników5.
Dzień dziecka w BullerbynMój XSL wygląda tak:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" media-type="text/xml"/>
<xsl:template match="/">
<html>
<head>
<title><xsl:value-of select="@title"/></title>
<meta http-equiv="Content-Language" content="pl"/>
<meta http-equiv="Content-Type" content="text/html; CHARSET=UTF-8"/>
</head>
<body>
<xsl:apply-templates select="//author"/>
</body>
</html>
</xsl:template>
<xsl:template match="author">
<xsl:variable name="aid" select='@id'/>
<xsl:variable name='book_count' select="count(//book[@author=$aid])"/>
<xsl:variable name='font_color'>
<xsl:choose>
<xsl:when test='$book_count>1'>gold</xsl:when>
<xsl:when test='$book_count=1'>green</xsl:when>
<xsl:otherwise>black</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<h1>
<font><xsl:attribute name='color'><xsl:value-of select='$font_color'/></xsl:attribute>
<xsl:apply-templates select='gname'/> <xsl:apply-templates select='sname'/>
</font>
</h1>
<ol>
<xsl:if test="$book_count">
<font> <xsl:attribute name="color">red</xsl:attribute>
<xsl:apply-templates select="//book[@author=$aid]"/>
</font>
</xsl:if>
</ol>
</xsl:template>
<xsl:template match='gname'>
<xsl:value-of select='text()'/>
</xsl:template>
<xsl:template match='book'>
<li>
<xsl:value-of select='title'/>
</li>
</xsl:template>
</xsl:stylesheet>
a część XML tak:
<baza>
<author id="1">
<gname>Astrid</gname>
<sname>Lindgren</sname>
</author>
<book id="1" author="1">
<title>Bracia Lwie Serce</title>
</book>
<book id="2" author="1">
<title>Braciszek i Karlsoon z dachu</title>
</book>
<book id="3" author="1">
<title>Dzieci z Bullerbyn</title>
</book>
<book id="4" author="1">
<title>Dzieci z z ulicy Awanturników</title>
</book>
<book id="5" author="1">
<title>Dzień dziecka w Bullerbyn</title>
</book>
</baza>
Jak widać mam też zrobione kolorowanie według ilości posiadanych książek, lecz chciałbym też dla odróżnienia żeby każdy wpis był np niebieski, a co drugi zielony.. Walcze z tym od dwóch dni i nie mam żadnych koncepcji...