0
我试图做的是改变背景颜色快速XSL文件,如果categorie将包含一个特定的词,但我不知道为什么不工作:(XSL:IF颜色没有更新XSLT
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="catalogo1.xsl"?>
<tienda>
<articulos>
<articulo>
<referencia ID="1">8354268</referencia>
<descripcion>Zapatillas de montaña Arpenaz 50 Negro</descripcion>
<departamento>Hombre</departamento>
<Categoria >Montaña</Categoria>
<colores>Negro Carbon/Gris Roca</colores>
<tallas>De 39 a 48</tallas>
<precio>Antes 19,99€ ahora 17,99€</precio>
<foto>images/8354268.jpg</foto>
<url>https://www.decathlon.es/zapatillas-de-montaa-arpenaz-50-negro--id_8354268.html</url>
</articulo>
<articulo>
<referencia ID="2">8383624</referencia>
<descripcion>CAMISETA DE DEPORTES DE RAQUETA ASICS SHOCKING NARANJA ASICS</descripcion>
<departamento>Hombre</departamento>
<Categoria>Fitness</Categoria>
<colores>Azul, verde, naranja</colores>
<tallas>S, M, L, XL</tallas>
<precio>34,99€</precio>
<foto>images/8383624.jpg</foto>
<url>https://www.decathlon.es/camiseta-shocking-naranja-id_8383624.html</url>
</articulo>
<articulo>
<referencia ID="3">8222527</referencia>
<descripcion>CHAQUETA SOFTSHELL SIBIR 500 CAMOFLUO SOLOGNAC</descripcion>
<departamento>Hombre</departamento>
<Categoria>Montaña</Categoria>
<colores>Estampado Naranja</colores>
<tallas>S, M, L, XL</tallas>
<precio>34,99€</precio>
<foto>images/8222527.jpg</foto>
<url>https://www.decathlon.es/polar-de-caza-de-hombre-softshell-sibir-500-id_8222527.html</url>
</articulo>
</articulos>
,这将是XSL文件:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head></head>
<body>
<h1>Test</h1>
<table border="1">
<tr bgcolor="green">
<th>Reference</th>
<th>Description</th>
<th>Departament</th>
<th>Categorie</th>
</tr>
<xsl:for-each select="tienda/articulos/articulo">
<!--- Error
<xsl:if test="Categoria = Montaña">
<td bgcolor="#00FF00">
Error -->
<xsl:sort select="departamento"/>
<tr>
<td>
<xsl:value-of select="referencia"/>
</td>
<td>
<xsl:value-of select="descripcion"/>
</td>
<td>
<xsl:value-of select="departamento"/>
</td>
<td>
<xsl:value-of select="Categoria"/>
</td>
</tr>
<!--- Error
</td>
</xsl:if>
Error -->
</xsl:for-each>
</table>
</body>
</html>
有没有人知道我为什么得到这个代码并且出错,而不是改变td的颜色?
提前许多感谢您的帮助
你究竟想在这里完成什么?抛开错误,将整行放在'td'元素中是没有意义的。 –
嗨@ michael.hor257k我试图做的是在字段类别中包含单词“Montaña”的行变成绿色?在这个XML文件中有三行,我希望1º和3ª行从白色变为绿色:) –