[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]


From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 22 Oct 2003 16:44:41 -0400 (EDT)

>	/xml parse r
>Date: Wed, 22 Oct 2003 09:37:54 -0700
>MIME-Version: 1.0
>X-Mailer: Internet Mail Service (5.5.2657.72)
>Content-Type: text/plain;
>	charset="ISO-8859-1"
>
>Thanks for the ideas on this issue.
>
>I ended up developing a SQL script to format the data as I wanted and
>eliminated the javascript altogether from this process.
>
>It was alot of pretty nasty code, but it got me where I wanted since I
>couldn't get this thing to work.
>
>Thanks,
>
>Tony
>
>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Mulberry
>Technologies List Owner
>Sent: Tuesday, October 21, 2003 4:18 PM
>To: xsl-list
>Subject: Re: [xsl] Problem sending node Array to Javascript using .NET
>xsl/xml parse r
>
>
>>From: "M. David Peterson" <conners_dad@xxxxxxx>
>>To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
>>References:
><1303AA14B8B7844FBE1F1810ECCD8098DC2E44@xxxxxxxxxxxxxxxxxxxxxxx>
>>Subject: Re: [xsl] Problem sending node Array to Javascript using .NET
>xsl/xml parse r
>>Date: Tue, 21 Oct 2003 00:36:48 -0600
>>
>>Hey Tony,
>>
>>I left on vacation right after we began this thread.  I apologize for the
>>late reply.  As far as I can tell this thread never got resolved.  Ive had
>a
>>bit of an issue with this in the past.  It seemed that every pass through
>>the node set (I would send the value of the node to a javascript variable
>to
>>store for later retrieval) I would get NaN as the value of the first node
>>every time.  As long as I didn't try to use the variable in any type of
>>concat or equation it wouldn't throw an error.  But as soon as I did it
>>would puke.  I never got to the bottom of it and as such I abandoned my
>>attempt to use javascript in this particular situation.  If this is the
>same
>>issue you are seeing (first node evaluates to NaN, the rest of the nodes
>>evaluate to there correct value) then I would simply set a 'var count = 0'
>>and then loop through it each time you run through your function. If count
>=
>>0 then set the var for the equation to a default value, otherwise use the
>>node value.  If this works then at least you can test to see if your
>>function works properly.  This is obviously not a long term solution but it
>>will at least help you debug.
>>
>>Your other option would be to test the node for an empty string value with
>><xsl:if> or <xsl:when> and send the function a default value when it
>>evaluates to true.
>>
>>Ill continue to research the whole NaN issue with the first node in a set
>as
>>this is something that has been troubling me in the back of my mind since I
>>ran into a few months back.  If I come across something Ill let you know.
>>
>>Best regards,
>>
>>M.
>>
>>
>>----- Original Message -----
>>From: "Disalvo, Anthony J." <ANTHONY.J.DISALVO@xxxxxxxx>
>>To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
>>Sent: Thursday, October 16, 2003 8:37 AM
> >Subject: RE: [xsl] Problem sending node Array to Javascript using .NET
>>xsl/xml parse r
>>
>>
>>> Joe,
>>>
>>> Here is a re-post of the original code for my problem.
>>>
>>> M., thanks for the ideas. unfortunately, I think that the value that is
>>> being sent to the jscript is null and jscript does not seem to allow a
>>> null
>>> parameter to be sent in whether it was the
>>> formatSigfigs(.,'AvgLabQARecovery') function or it is the
>setNodeValue(.)
>>> function.
>>>
>>> As a result it throws an error before it event tries to execute any of
>the
>>> code within the jscript function.
>>>
>>> Anyone know of a way to set a default for a parameter in a jscript if the
>>> parameter sent in is null.
>>>
>>> Thanks,
>>>
>>> Tony
>>>
>>> //////////////////////////////XML
>>>
>INPUT///////////////////////////////////////////////////////////////////////
> >> /
>>>
>>> <Report ReportID="QC-03" ReportTitle="Laboratory Report Sample - Percent
>>> Recovery">
>>> <Group GroupCategory="Sampling Event List"
>GroupValue="25,35,45,55,65,75">
>>> <AnalyteData LabResultsTypeName="LCS" LabResultsTypeDescription="Result
>>> from
>>> a lab control sample" Analyte="Americium-241"
>AnalyticalMethodType="RGAMM"
>>> AvgLabQARecovery="99.000000000000" MinLabQARecovery="99.000000000000"
>>> MaxLabQARecovery="99.000000000000" AnalyteCount="2"/>
>>> <AnalyteData LabResultsTypeName="LCS" LabResultsTypeDescription="Result
>>> from
>>> a lab control sample" Analyte="Cesium-137" AnalyticalMethodType="RGAMM"
>>> AvgLabQARecovery="105.367005227874" MinLabQARecovery="97.000000000000"
>>> MaxLabQARecovery="107.709999084473" AnalyteCount="531"/>
>>> <GroupList GroupListValue="25" GroupListText="Cotto-Waxo
>>> (DT14)-Verification-Class 2"/>
>>> <GroupList GroupListValue="35" GroupListText="Plant 1 (Small Area #11
>>> North)-Verification-Class 1"/>
>>> </Group>
>>> </Report>
>>>
>>>
>////////////////////////////////////////////////////////////////////////////
>> > /////////////////////////////////////////
>>>
>>> //////////////////////////////////////////XSL
>>> INPUT//////////////////////////////////////////////////////////////
>>>
>>> <?xml version="1.0"?>
>>> <xsl:stylesheet version="1.0"
>>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>>  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
>>>  xmlns:auto-nsl="http://www.w3.org/TR/WD-xsl"
>>>  xmlns:local="urn:galileo-com:msxsl-jscript-utilities" >
>>> <xsl:template match="/">
>>> <xsl:for-each select="Report">
>>> <table width="800px" border="1" cellpadding="0" cellspacing="0" >
>>> <xsl:choose>
>>> <xsl:when test="Group">
>>> <tr><td>
>>> <table border="1" width="100%" cellpadding="0" cellspacing="0">
>>> <tr><td width="50%">Report Code</td><td
>>> width="50%"><xsl:value-of select="@ReportID"/></td></tr>
>>> <tr><td width="50%">Report Name</td><td
>>> width="50%"><xsl:value-of select="@ReportTitle"/></td></tr>
>>> </table>
>>> <xsl:for-each select="Group">
>>> <table>
>>> <xsl:choose>
>>> <xsl:when test="GroupList">
>>> <tr>
>>> <td><xsl:value-of
>>> select="@GroupCategory"/></td>
>>> <td></td>
>>> </tr>
>>> <xsl:for-each select="GroupList">
>>> <tr>
>>> <td></td>
>>> <td><xsl:value-of
>>> select="@GroupListText"/></td>
>>> </tr>
>>> </xsl:for-each>
>>> </xsl:when>
>>> <xsl:otherwise>
>>> <tr>
>>> <td><xsl:value-of
>>> select="@GroupCategory"/></td>
>>> <td><xsl:value-of
>>> select="@GroupValue"/></td>
>>> </tr>
>>> </xsl:otherwise>
>>> </xsl:choose>
>>> </table>
>>> <table cellpadding="0" cellspacing="0" class="rptHeadBold"
>>> border="1" width="100%">
>>> <tr>
>>> <td align="right" width="17%">Analyte</td>
>>> <td align="right" width="17%">Analytical
>>> Method Type</td>
>>> <td align="right" width="17%">Average Lab
>>> Value</td>
>>> <td align="right" width="17%">Min Lab
>>> Value</td>
>>> <td align="right" width="16%">Max Lab
>>> Value</td>
>>> <td align="right" width="16%">Analyte
>>> Count</td>
>>> </tr>
>>> </table>
>>> <table border="1" width="100%" cellpadding="0"
>>> cellspacing="0" >
>>> <xsl:for-each select="AnalyteData">
>>> <tr>
>>> <td align="right" width="17%"><xsl:value-of
>>> select="@Analyte"/></td>
>>> <td align="right" width="17%"><xsl:value-of
>>> select="@AnalyticalMethodType"/></td>
>> > <td align="right" width="17%"><xsl:value-of
> >> select="local:formatSigfigs(.,'AvgLabQARecovery')"/></td>
>>> <td align="right" width="17%"><xsl:value-of
>>> select="local:formatSigfigs(.,'MinLabQARecovery')"/></td>
>>> <td align="right" width="16%"><xsl:value-of
>>> select="local:formatSigfigs(.,'MaxLabQARecovery')"/></td>
>>> <td align="right" width="16%"><xsl:value-of
>>> select="@AnalyteCount"/></td>
>>> </tr>
>>> </xsl:for-each>
>>> </table>
>>> </xsl:for-each>
>>> </td></tr>
>>> </xsl:when>
>>> <xsl:otherwise>
>>> <tr>
>>> <td align="center">No data was returned for the selected
>>> parameters.</td>
>>> </tr>
>>> </xsl:otherwise>
>>> </xsl:choose>
>>> </table>
>>> </xsl:for-each>
>>> </xsl:template>
>>> <msxsl:script language="JavaScript" implements-prefix="local">
>>> <![CDATA[
>>> function formatSigfigs (oNodeList,ColumnName)
>>> {
>>> var oNode = oNodeList.item(0);
> >>
>>>
>>> //var numberVal = oNode.getAttribute('AvgLabQARecovery');
>>> var numberVal = oNode.getAttribute(ColumnName);
>>> if ((numberVal >= 1000000)||(numberVal <= 0.0001))
>>> {
>>> var exponentVal;
>>>
>>> if (numberVal >= 1000000)
>>> {
>>> exponentVal = 5;
>>> numberVal = numberVal/1000000
>>> while(numberVal > 10)
>>> {
>>> numberVal = numberVal/10;
>>> exponentVal = exponentVal + 1;
>>> }
>>> numberVal = formatNumber(numberVal,"0.00") + "E+" +
>>> formatNumber(exponentVal,"0");
>>> }
>>> else
>>> {
>>> exponentVal = -4;
>>> numberVal = numberVal* 10000;
>>> while(numberVal < 1)
>>> {
>>> numberVal = numberVal*10;
>>> exponentVal = exponentVal - 1;
>>> }
>>> numberVal = formatNumber(numberVal,"0.00") + "E" +
>>> formatNumber(exponentVal,"0");
>>> }
>>>
>>> }
>>>
>>> else if (numberVal >= 100000){numberVal =
>>> (formatNumber(numberVal,"#,##0").substr(0,4) + "000");}
>>> else if (numberVal >= 10000){numberVal =
>>> (formatNumber(numberVal,"#,##0").substr(0,4) + "00");}
>>> else if (numberVal >= 1000){numberVal =
>>> (formatNumber(numberVal,"#,##0").substr(0,4) + "0");}
>>> else if (numberVal >= 100){numberVal = formatNumber(numberVal,"#,##0");}
>>> else if (numberVal >= 10){numberVal = formatNumber(numberVal,"#,##0.0");}
>>> else if (numberVal >= 1){numberVal = formatNumber(numberVal,"#,##0.00");}
>> > else if (numberVal >= 0.1){numberVal =
>>> formatNumber(numberVal,"#,##0.000");}
>>> else if (numberVal >= 0.01){numberVal =
>>> formatNumber(numberVal,"#,##0.0000");}
>>> else if (numberVal >= 0.001){numberVal =
>>> formatNumber(numberVal,"#,##0.00000");}
>>> return numberVal;
>>> }
>>>   var separator = ",";  // use comma as 000's separator
>>>   var decpoint = ".";  // use period as decimal point
>>>   var percent = "%";
>>>   var currency = "$";  // use dollar sign for currency
>>>
>>>   function formatNumber(number, format, print) {  // use:
>>> formatNumber(number, "format")
>>>     if (print) document.write("formatNumber(" + number + ", \"" + format
>+
>>> "\")<br>");
>>>
>>>     if (number - 0 != number) return null;  // if number is NaN return
>>> null
>>>     var useSeparator = format.indexOf(separator) != -1;  // use
>separators
>>> in number
>>>     var usePercent = format.indexOf(percent) != -1;  // convert output to
>>> percentage
>>>     var useCurrency = format.indexOf(currency) != -1;  // use currency
>>> format
>>>     var isNegative = (number < 0);
>>>     number = Math.abs (number);
>>>     if (usePercent) number *= 100;
>>>     format = strip(format, separator + percent + currency);  // remove
>key
>>> characters
>>>     number = "" + number;  // convert number input to string
>>>
>>>      // split input value into LHS and RHS using decpoint as divider
>>>     var dec = number.indexOf(decpoint) != -1;
>>>     var nleftEnd = (dec) ? number.substring(0, number.indexOf(".")) :
>>> number;
>>>     var nrightEnd = (dec) ? number.substring(number.indexOf(".") + 1) :
>>> "";
>>>
>>>      // split format string into LHS and RHS using decpoint as divider
>>>     dec = format.indexOf(decpoint) != -1;
>>>     var sleftEnd = (dec) ? format.substring(0, format.indexOf(".")) :
>>> format;
>>>     var srightEnd = (dec) ? format.substring(format.indexOf(".") + 1) :
>>> "";
>>>
>>>      // adjust decimal places by cropping or adding zeros to LHS of
>number
>>>     if (srightEnd.length < nrightEnd.length) {
>>>       var nextChar = nrightEnd.charAt(srightEnd.length) - 0;
> >>       nrightEnd = nrightEnd.substring(0, srightEnd.length);
>> >       if (nextChar >= 5) nrightEnd = "" + ((nrightEnd - 0) + 1);  //
>round
>>> up
>>>
>>>  // patch provided by Patti Marcoux 1999/08/06
>>>       while (srightEnd.length > nrightEnd.length) {
>>>         nrightEnd = "0" + nrightEnd;
>>>       }
>>>
>>>       if (srightEnd.length < nrightEnd.length) {
>>>         nrightEnd = nrightEnd.substring(1);
>>>         nleftEnd = (nleftEnd - 0) + 1;
>>>       }
>>>     } else {
>>>       for (var i=nrightEnd.length; srightEnd.length > nrightEnd.length;
>>> i++)
>>> {
>>>         if (srightEnd.charAt(i) == "0") nrightEnd += "0";  // append zero
>>> to
>>> RHS of number
>>>         else break;
>>>       }
>>>     }
>>>
>>>      // adjust leading zeros
>>>     sleftEnd = strip(sleftEnd, "#");  // remove hashes from LHS of format
> >>     while (sleftEnd.length > nleftEnd.length) {
>>>       nleftEnd = "0" + nleftEnd;  // prepend zero to LHS of number
>>>     }
>>>
>>>     if (useSeparator) nleftEnd = separate(nleftEnd, separator);  // add
>>> separator
>>>     var output = nleftEnd + ((nrightEnd != "") ? "." + nrightEnd : "");
>>> //
>>> combine parts
>>>     output = ((useCurrency) ? currency : "") + output + ((usePercent) ?
>>> percent : "");
>>>     if (isNegative) {
>>>       // patch suggested by Tom Denn 25/4/2001
>>>       output = (useCurrency) ? "(" + output + ")" : "-" + output;
>>>     }
>>>     return output;
>>>   }
>>>
>>>   function strip(input, chars) {  // strip all characters in 'chars' from
>>> input
>>>     var output = "";  // initialise output string
>>>     for (var i=0; i < input.length; i++)
>>>       if (chars.indexOf(input.charAt(i)) == -1)
>>>         output += input.charAt(i);
>>>     return output;
>>>   }
>>>
>>>   function separate(input, separator) {  // format input using
>'separator'
>>> to mark 000's
>>>     input = "" + input;
>>>     var output = "";  // initialise output string
>>>     for (var i=0; i < input.length; i++) {
>>>       if (i != 0 && (input.length - i) % 3 == 0) output += separator;
>>>       output += input.charAt(i);
>>>     }
>>>     return output;
>>>   }
>>>   ]]>
>>>  </msxsl:script>
>>> </xsl:stylesheet>
>>>
>>> -----Original Message-----
>> > From: M. David Peterson [mailto:conners_dad@xxxxxxx]
>>> Sent: Thursday, October 16, 2003 4:22 AM
>>> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>>> Subject: RE: [xsl] Problem sending node Array to Javascript using .NET
>>> xsl/xml parse r
>>>
>>>
>>> It seems to me that one of three things are happening... One, the content
>>> of
>>>
>>> the context node is empty an therefore returns an empty string (the
>>> JScript
>>> engine they are using doesnt like empty strings).  Two, there is a type
>>> conversion issue that is not being addressed correctly in the transport
>to
>>> the Javascript engine (ive seen this happen quite a bit, especially
>>> running
>>> on top of .NET using XslTransform() ). Three, somehow the call to the
>>> javascript function is interupting the connection to the current node and
>>> therefore sends null or an empty string or NaN or whatever.  There are a
>>> few
>>>
>>> solutions I can think of, but the easiest to me would be this...
>>>
>>> Within your loop set a variable equal to the context node.
>>>
>>> <xsl:variable name="current" select="."/>
>>>
>>> Then just call the variable from within the call to the Javascript
>>> function...
>>>
>>> <xsl:value-of select="local:formatSigfigs($current,'AvgLabQARecovery')"/>
>>>
>>>
>>> You could also set a javascript global variable to the value of the
>>> current
>>> node and then use that within the formatSigfigs() function.
>>>
>>> Heres the Javascript...
>>>
>>>
>>>         var nodeValue;
>>>
>>>         function setNodeValue(value){
>>>             try{
>>>                nodeValue = value;
>>>                return 0;
>>>             }
>>>             catch{
>>>                return 1;
>>>             }
>>>         }
>>>
>>>
>>> And heres the XSLT...
>>>
>>> <xsl:choose>
>>>    <xsl:when test="local:setNodeValue(.) = 0">
>>>         <xsl:value-of select="local:formatSigfigs('AvgLabQARecovery')"/>
>>> //Note: change the local:formatSigFigs() function to use the global var
>>> 'nodeValue' to process and return the correct value
> >>    </xsl:when>
>>>    <xsl:otherwise>
>>>         put something in here to tell you that the value didnt get set
>>> correctly.
>>>    </xsl:otherwise>
>> > </xsl:choose>
>>>
>>> Using the above javascript variable solution would also allow you to call
>>> a
>>> returnValue function from an <xsl:value-of> element to determine what is
>>> actually being sent to the javascript function...
>>>
>>> Something like:
>>>
>>> function returnNodeValue(){
>>>
>>>    return nodeValue;
>>>
>>> }
>>>
>>> and then call it with:
>>>
>>> <xsl:value-of select="local:returnNodeValue()"/>
>>>
>>> If you are getting the correct string written out then at least you know
>>> youve got that part of the problem solved.
>>>
>>> I hope this helps!
>>>
>>> Best regards,
>>>
>>> M.
>>>
>>>
>>>
>>>
>>>
>>> >From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx>
> >> >Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>>> >To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>>> >Subject: RE: [xsl] Problem sending node Array to Javascript using .NET
>>> >xsl/xml parse r
>>> >Date: Thu, 16 Oct 2003 08:41:08 +0100
>>> >
>>> >I missed the first part of this, can you show a sample of the offending
>>> >code?
>>> >
>>> >--
>>> >
>>> >Joe
>>> >
>>> >
>>> >>From: "Disalvo, Anthony J." <ANTHONY.J.DISALVO@xxxxxxxx>
>>> >>Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>>> >>To: "'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'"
>>> >><xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
>>> >>Subject: RE: [xsl] Problem sending node Array to Javascript using .NET
>>> >>xsl/xml parse r
>>> >>Date: Wed, 15 Oct 2003 11:17:37 -0700
>>> >>
>>> >>Thanks for the Idea, I tried this and it did not work.
>>> >>
>>> >>
>>> >>-----Original Message-----
>>> >>From: Wendell Piez [mailto:wapiez@xxxxxxxxxxxxxxxx]
>>> >>Sent: Tuesday, October 14, 2003 2:16 PM
>>> >>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>>> >>Subject: Re: [xsl] Problem sending node Array to Javascript using .NET
>>> >>xsl/xml parse r
>>> >>
>>> >>
>>> >>Anthony,
>>> >>
>>> >>At 12:25 PM 10/14/2003, you wrote:
>>> >> >It is having a problem with the following line of code: <xsl:value-of
>>> >> >select="local:formatSigfigs(.,'AvgLabQARecovery')"/>
>>> >> >
>>> >> >It does not like the period/decimal point being sent in to the
>>> >>javascript
>>> >>as
>>> >> >a reference to the node.
>>> >> >
>>> >> >Any ideas on how to deal with this issue or alternatives on how tro
>>> >> >reference the node not using the period / decimal point that will
>pass
>> > >>the
>>> >> >Microsoft parser's requirements?
>>> >>
>>> >>I have no idea whatsoever as to working with the MS toolkit, but you
>>> >>might
>>> >>try
>>> >>
>>> >>self::node()
>>> >>
>>> >>which is the XPath expression commonly abbreviated as "."
>>> >>
>>> >>Whether it works for you here is another question.
>>> >>
>>> >>Cheers,
>>> >>Wendell
>>> >>
>>> >>
>>> >>======================================================================
>>> >>Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
>>> >>Mulberry Technologies, Inc.                http://www.mulberrytech.com
>>> >>17 West Jefferson Street                    Direct Phone: 301/315-9635
>>> >>Suite 207                                          Phone: 301/315-9631
>>> >>Rockville, MD  20850                                 Fax: 301/315-8285
>>> >>----------------------------------------------------------------------
>>> >>    Mulberry Technologies: A Consultancy Specializing in SGML and XML
>>> >>======================================================================
>>> >>
>>> >>
>>> >>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>>> >>
>>> >>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>>> >>
>>> >
>>> >_________________________________________________________________
>>> >Find a cheaper internet access deal - choose one to suit you.
>>> >http://www.msn.co.uk/internetaccess
>>> >
>>> >
>>> >XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>>> >
>>>
>>> _________________________________________________________________
>>> Want to check if your PC is virus-infected?  Get a FREE computer virus
>>> scan
>>> online from McAfee.
>>> http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>>>
>>>
>>>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> >>
>>>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>>>
>>>
>
>
>--
>======================================================================
>B. Tommie Usdin                        mailto:btusdin@xxxxxxxxxxxxxxxx
>Mulberry Technologies, Inc.                http://www.mulberrytech.com  
>17 West Jefferson Street                           Phone: 301/315-9631
>Suite 207                                    Direct Line: 301/315-9634
>Rockville, MD  20850                                 Fax: 301/315-8285
>----------------------------------------------------------------------
>  Mulberry Technologies: A Consultancy Specializing in  XML and SGML
>======================================================================
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
Sender: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Precedence: bulk
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
X-MailLoop: 1



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



Current Thread
  • [no subject]
    • owner-xsl-list - Wed, 22 Oct 2003 16:44:41 -0400 (EDT) <=
Keywords