Re: [xsl] How do i check null values in a for each???

Subject: Re: [xsl] How do i check null values in a for each???
From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx>
Date: Tue, 30 Apr 2002 12:26:10 +0000
Hi suman assuming that ur XML looks like ..

<attributes>
<attr name = "addrdesc">
<value>value1</value>
</attr>
<attr name = "AddrDesc">
<value>value2</value>
</attr>
</attributes>

your xsl would be ..

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
<xsl:for-each select="/attributes/attr">
<td>&#160; <input type="text">
<xsl:attribute name="name">txtAddressDesc</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="value[(parent::attr/@name='addrdesc1') or (parent::attr/@name = 'AddrDesc1')]"></xsl:value-of></xsl:attribute>
</input>
</td>
</xsl:for-each>


</xsl:template>
</xsl:stylesheet>

This works FOR THE XML STRUCTURE I HAVE ASSUMED.
---- XSL Gurus .. please advise if there are better ways to do this. ---
vasu

From: Suman.Sathyanarayan@xxxxxxxxxxxx
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] How do i check null values in a for each???
Date: Tue, 30 Apr 2002 16:32:42 +0530


Hi Laura,Mr Kay,Vasu. and of course everyone on the list.

Me again.


Please see the following snippet:



<xsl:for-each select="attr[@name='addrdesc1' or @name='AddrDesc1']"> <td>  <input type="text"> <xsl:attribute name="name">txtAddressDesc</xsl:attribute> <xsl:attribute name="value"><xsl:value-of select ="value"></xsl:value-of></xsl:attribute> </input> </td> </xsl:for-each>



Now consider for instance the above for-each does'nt return a value at all.
I.e there is'nt an attribute called addrdesc1 in the xml schema response
So obviously it does't enter the for-each and does NOT display the text
box.

but i still want to display an empty text box to the user
in the XSL , How do i do this???

May be i can get a count, or something


Regards, Suman



-----------------------Disclaimer------------------------

The views of the author may not necessarily reflect those
of the Company. All liability is excluded to the extent
permitted by law for any claims arising as a result of the
use of this medium to transmit information by or to
IT Solutions (India) Pvt. Ltd.

We have taken precautions to minimize the risk of
transmitting software viruses, but we advise you to
carry out your own virus checks on any attachment to
this message.  We cannot accept liability for any loss or
damage caused by software viruses.

------------------------Disclaimer------------------------


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list






_________________________________________________________________
Join the world?s largest e-mail service with MSN Hotmail. http://www.hotmail.com



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread