xsl-list
[Top] [All Lists]

[xsl] Determining if an optional attribute is present

2006-10-17 09:37:05
Determining if an optional attribute is present

Here is the source XML:

<node id="1" version="1">
</node>
<node id="4" version="3" revision="2">
</node>

Here is the output I need:

<node id="1" version="1" revision="0">
</node>
<node id="4" version="3" revision="2">
</node>

Logically it would seem that this would do it:

<xsl:attribute name="revision">
 <xsl:if test="not(string(@revision)) = false()">
   <xsl:value-of select="@revision"/>
 </xsl:if>
 <xsl:if test="not(string(@revision))">
   <xsl:text>0</xsl:text>
 </xsl:if>
</xsl:attribute>

But in both cases, whether or not the revision is present,
not(string(@revision)) always returns false.  I have tried this with
both the debugger in XMLSpy and with MSXML 4.0.  The target parser is
MS .Net 2.0.

Sam
--
Miltonstreet Photography
http://www.miltonstreet.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--