xsl-list
[Top] [All Lists]

[xsl] Writing array elements based on a an evaluation of one of the child elements

2006-05-24 03:11:03
Hi there

I'm trying to write some XSL that ommits a bunch of Null and Zero array 
elements from the XML.
In my XSLT, when I see the ACCOUNT-LIST  element I want to write a parent 
element called ACCOUNT-LIST . Then I want to write out the child-elements of 
ACCOUNT-LIST and their values only if the string-length in the current 
occurence of ACCOUNT-NO is greater than 0.
So I try using an xsl:choose and xsl:when as follows...

<xsl:template match = "ACCOUNT_LIST">
<xsl:element name = "ACCOUNT-LIST">     
     <xsl:choose>
    <xsl:when test="count(//ACCOUNT-NO[string-length(.) > 0])">
        <xsl:element name = "ACCOUNT-NO">
        <xsl:value-of select="."/>
    </xsl:element>
    <xsl:element name = "SBU-CODE">
   <xsl:value-of select = "."/>
  </xsl:element>
  <xsl:element name = "RISK_TYPE">
   <xsl:value-of select = "."/>
  </xsl:element>
       </xsl:when>
      </xsl:choose>  
</xsl:element>
</xsl:template>

But it writes out all the data without creating tags - what am I doing wrong 
here?

Regards
Neil

--~------------------------------------------------------------------
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>
--~--