xsl-list
[Top] [All Lists]

[xsl] How do I avoid NaN (Simple Maths)

2008-03-13 03:36:12
Hello Xsl-list,

How do I do simple addition but avoid Nan when elements are not in
Xml.
i.e  /count is 0(zero) and hence element <Table1> is not included
 say
 <Table1><callResultCode>25</callResultCode>...</Table1> whole
 element not included

    I'm using Xml v1.0 and Xsl v1.0

  Simple maths total=x1+x2+x3...+xN
  n is 0 to 20

  callResultCode in range 1-280

  In e.g. below I want      $clientContacted=  6 + 1
  I'm getting NaN (I assume this is because other elements are not
  present)

  Xml Structure
  (A bit ugly but for ease "default from a database". It  is changeable)

  <NewDataSet>
  <Table>
      ...
  </Table>
  <Table1>
    <callResultCode>280</callResultCode>
    <callResultDescription>Client agree</callResultDescription>
    <count>6</count>
  </Table1>
  <Table1>
    <callResultCode>29</callResultCode>
    <callResultDescription>Elderly / Infirm (incapable of decision 
making)</callResultDescription>
    <count>1</count>
  </Table1>
  ...
  </NewDataSet>

     Variable(s) poupulated at head of Xsl file (works OK when all
     elements present)

     <xsl:variable name="clientContacted" 
select="NewDataSet/Table1[callResultCode=280]/count
        + NewDataSet/Table1[callResultCode=25]/count 
        + NewDataSet/Table1[callResultCode=281]/count
        + NewDataSet/Table1[callResultCode=28]/count
        + NewDataSet/Table1[callResultCode=29]/count
        + NewDataSet/Table1[callResultCode=36]/count"/>

        <xsl:variable name="extinctRecords" select="$clientContacted
        + NewDataSet/Table1[callResultCode=30]/count
        + NewDataSet/Table1[callResultCode=6]/count"/>


Best regards,
 Arthur                          mailto:ArthurM(_at_)seipas(_dot_)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>
--~--

<Prev in Thread] Current Thread [Next in Thread>