?
Solved

Preventing exponential representation of numeric data from SP using XML/XSLT

Posted on 2004-04-14
4
Medium Priority
?
825 Views
Last Modified: 2010-05-18
Below is my format specification but on occasion, a large balance will be represented exponentially (1,259,951,501.00 is displayed as 1.259951501E9). I know the SP doesn't return the value this way. How can I capture the value and prevent the XSL from representing the value this way?

Thanks, Nefertiti_IT

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" omit-xml-declaration="yes"/>

<xsl:template match="/">
        <xsl:apply-templates select="/dML/row/"/>
</xsl:template>

<xsl:template match="row">    
        <xsl:value-of select="Name"/><xsl:text>|</xsl:text>
        <xsl:value-of select="Acct"/><xsl:text>|</xsl:text>
        <xsl:value-of select="CheckingAcctBalance"/><xsl:text>|</xsl:text>    
        <xsl:value-of select="SavingsAcctBalance"/><xsl:text>|</xsl:text>
        <!-- End of row -->
        <xsl:text>&#010;</xsl:text>
</xsl:template>

</xsl:stylesheet>
0
Comment
Question by:Nefertiti_IT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 26

Expert Comment

by:rdcpro
ID: 10826808
It can't be the XSLT...the XSLT doesn't know anything about data types, unless there's something about your XML/XSLT that you're not showing.  As far as

<xsl:value-of select="SavingsAcctBalance"/>

goes, this is just a string, and the XSLT will display whatever is in the SavingsAcctBalance element.

I'd double check the XML that's being transformed...you'll find the number is already in that form.

It's possible, though this may not work, that you can fix this in the XSLT using the format-number function.  But I rather doubt it will work:

<xsl:value-of select="format-number(SavingsAcctBalance, '#0.00')"/>

Regards,
Mike Sharp
0
 

Author Comment

by:Nefertiti_IT
ID: 10826893
Hi Mike,

Thanks for responding...there are a few other files involved in this and I would guess the problem might be here with the below declaration. Is it the attribute setting (or lack thereof) that could be causing this?

Thanks again,
Nefertiti_IT

<xsl:template match="row-set">
        <xsl:for-each select="row">
                <row>
                        <xsl:apply-templates select="col"/>
                </row>
        </xsl:for-each>
</xsl:template>



<xsl:template match="col">
        <xsl:element name="{@column-label}">
                <xsl:value-of select="normalize-space(text())"/>
         </xsl:element>
</xsl:template>
0
 
LVL 26

Accepted Solution

by:
rdcpro earned 200 total points
ID: 10827346
If it's actually an XSLT *number* datatype (which is not evident from what you've shown) there is a limitation on the maximum *precision*.  But if it's a string, there's no way the XSLT you posted could do this.  For example:

This XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
      <xsl:template match="/">
            <xsl:variable name="vNum" select="123456789012345678901234567890.00"/>
            <xsl:variable name="vNumString" select=" '123456789012345678901234567890.00' "/>
            <xsl:value-of select="$vNum"/><br/>
            <xsl:value-of select="$vNumString"/>
      </xsl:template>
</xsl:stylesheet>


Produces this:

123456789012345670000000000000
123456789012345678901234567890.00

So you can see that the max precision 17 sig figs.  But the string gets it all. Neither one produces 1.2345678901234567E29

It must be happening before the XSLT gets it.  If you use this XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
      <xsl:template match="/">
            <xsl:copy-of select="*"/>
      </xsl:template>
</xsl:stylesheet>


It will show you that the value is already in the other format.  I'll bet either your SP *does* produce the number in the exp format, or else some other intermediate step strongly types the number and does it.  

Regards,
Mike Sharp
0
 

Author Comment

by:Nefertiti_IT
ID: 10828110
Mike,

You are right! Running the SP in the database produced the values I expected but the data does reach my xml format doc. in exponential format. I converted the large values to "numeric" in the SP and the problem is solved. Thank you very much for your help!!!!

Nefertiti
0

Featured Post

Python: Series & Data Frames With Pandas

Learn the basics of Python’s pandas library of series & data frames and how we can use these tools for data manipulation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month10 days, 2 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question