I am finally working on developing my first "pure" XML web site, mostly as an experiment. Trying to figure out how to convert the XML data files to XHTML using XSLT, I have found that there seem to be very few comprehensive tutorials on this technology, and I am hoping someone here will be able to get me past the first of what I am sure will be many stumbling blocks.
My question is, how do I test for a false condition? <xsl:if test="@name"> will execute if there is an attribute called name, but how can I get it to execute if name does not exist? The same thing applies with comparing values. If I want to check if name is not Tom, @name != 'Tom' does not work.
Also, as part of the same issue, is there a way to get an XSL template to output an invalid tag? Basically, if an element is found without the specified tag, I want to output a closing tag, followed by a new opening tag. I am trying to create a new row in a table when this happens. However, the closing tag causes the file to no longer be valid XML, and it doesn't process. Do I need to use a CDATA container or something else?
Here is my current, bad code.
Code:
<table><tr>
<xsl:for-each select="parameter">
<td><xsl:value-of select="@data" /></td>
<xsl:if test="@number != '3'">
</tr><tr>
</xsl:if>
</xsl:for-each>
</tr></table>