Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-04-14
4
Medium Priority
?
845 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

609 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