D
Digital Puer
I am trying to use XSL to parse XML into HTML, but
I'm having a hard time with parsing XML attributes.
My XML looks like this:
<td> data </td>
<td width="10"> data </td>
I want the resulting HTML to look exactly like the above!
My XSL looks like this:
----
<xsl:template match="td">
<td>
<xsl:attribute name="width">
<xsl:value-of select="@width"/>
</xsl:attribute>
<xsl:apply-templates/>
</td>
</xsl:template>
----
However, this produces:
<td width=""> data </td>
<td width="10"> data </td>
Can someone answer the following questions:
1. How can the 'width=""' be removed if there is no 'width' attribute'?
2. can someone comment if the above template is the right way to go
to process XML attributes, in general? I'm a newbie. thanks.
I'm having a hard time with parsing XML attributes.
My XML looks like this:
<td> data </td>
<td width="10"> data </td>
I want the resulting HTML to look exactly like the above!
My XSL looks like this:
----
<xsl:template match="td">
<td>
<xsl:attribute name="width">
<xsl:value-of select="@width"/>
</xsl:attribute>
<xsl:apply-templates/>
</td>
</xsl:template>
----
However, this produces:
<td width=""> data </td>
<td width="10"> data </td>
Can someone answer the following questions:
1. How can the 'width=""' be removed if there is no 'width' attribute'?
2. can someone comment if the above template is the right way to go
to process XML attributes, in general? I'm a newbie. thanks.