[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How do I avoid NaN (Simple Maths)

Subject: How do I avoid NaN (Simple Maths)
From: Arthur Maloney <ArthurM@xxxxxxxxxx>
Date: Thu, 13 Mar 2008 10:35:41 +0000
 How do I avoid  NaN (Simple Maths)
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@xxxxxxxxxx

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.