Solved

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

Posted on 2004-04-14
4
783 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
  • 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 50 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now