Subject: [xsl] Problem with empty element check ! From: "Shamik Bandopadhyay -X \(sbandopa - TCS at Cisco\)" <sbandopa@xxxxxxxxx> Date: Tue, 11 Jul 2006 03:03:13 +0530 |
Hi, I'm facing an issue with an empty element check using XSLT.Here's my sample XSLT.I'm checking whether <money> has a value,id yes I'm printing,else skip.But,even if there's no value or the tag doesn't exist,the control is getting inside the xsl:if check and printing the bullets.Any pointers will be appreciated. Here's the xsl I'm using. <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Title</th> <th>Artist</th> </tr> <xsl:for-each select="catalog/cd"> <xsl:variable name="empty_string" select="money"/> <xsl:if test="not($empty_string = normalize-space(.))"> <tr> <td> <ul> <li> <xsl:value-of select="money"/> </li> </ul> </td> <xsl:value-of select="name()"/> </tr> </xsl:if> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> Here's the sample XML: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="catalog.xsl"?> <catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <price> <currency>Pound</currency> </price> </cd> <cd> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> <price> <currency>Pound</currency> </price> <money>22</money> </cd> <cd> <title>Greatest Hits</title> <artist>Dolly Parton</artist> <price> <currency>Pound</currency> </price> <money>33</money> </cd> <cd> <artist>John Denver</artist> <price>50</price> <money></money> </cd> </catalog> Thanks
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XML->HTML tables with bla, Mukul Gandhi | Thread | RE: [xsl] Trying to figure out the , Austin, Darrel |
[xsl] XML->HTML tables with blank c, Carmen Pancerella | Date | RE: [xsl] Trying to figure out the , Austin, Darrel |
Month |