This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE:


><DEPOSIT>
>  <A>fixedDeposit</A>
>  <B>RecurringDeposit</B>
></DEPOSIT>
>
>In the above mentioned case, some times the value of
>either A or B will be null, but while i extract the
>info through stylesheet, i have to check for the
>element which has null and i must not print it.

Here's one way that only copies the element if its contents is not equal to
an empty string:

  <xsl:template match="A|B">
    <xsl:if test=". !=''">
      <xsl:copy><xsl:apply-templates/></xsl:copy>
    </xsl:if>
  </xsl:template>                     

I'm sure there are other approaches. This way assumes that an empty A
element is represented as <A></A> or as <A/>. Potential whitespace will
complicate the situation. 

Also, keep in mind that with schemas, real null values (as opposed to empty
elements) will be possible.

Bob DuCharme          www.snee.com/bob           <bob@  
snee.com>  "The elements be kind to thee, and make thy
spirits all of comfort!" Anthony and Cleopatra, III ii


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]