# Forcing a decimal point on the first digit

Ok i have a xml file and a xsl file.
I have managed to display all the data the way i wanted with one exception.
The xml file as a numeric value of a north south west east designation by numbers.
south and west would be a negative number and a north east would be a postive number.
I can get the numbers to show correctly to a point.
As all coordinates have a decimal point in reality.
Though the xml file only gives a whole number.
Here are the two lines of code i  am talking about
First this is from the xml file.
<location NS="575" WE="-528">
This is the lines of code in the xsl file to give the proper view im looking for.
<td bgcolor="#ffffff"><xsl:value-of select="format-number(number(location/@NS),'#,N;#,S')" /></td>
<td bgcolor="#ffffff"><xsl:value-of select="format-number(number(location/@WE),'#,E;#,W')" /> </td>

What will show when you look at the html view will be
575N 528W
What im looking for is 57.5N 52.8W so im looking for a solution on how to force a decimal point one digit over.
Mind you i am more then a beginner at this meaning i have no training what so ever in xml or xsl
So please be specfic in what you say to me as so i can understand what you are telling me.
LVL 2
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
i think the easiest way is to divide number on 10 :)

see:
<xsl:value-of select="format-number(number(location/@NS div 10),'00.0N;00.0S')" />

and

<xsl:value-of select="format-number(number(location/@WE div 10),'00.0E;00.0W')" />
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
if the substring is always 3 digits long you can use a variable

<!-- this selects the whole string eg 575 -->
<xsl:variable name="wholeNumber"><xsl:value-of select="location/@WE"/></xsl:variable>
<!-- this selects only the first 2 digits start at the first value (5) and select 2 digits -->
<xsl:variable name="First2digits"><xsl:value-of select="substring(location/@WE,1,2 )"/></xsl:variable>
<!-- this selects only the 3rd digit: start at the second  value (7) and select 1 digits -->
<xsl:variable name="lastdigit"><xsl:value-of select="substring(location/@WE,2,1 )"/></xsl:variable>

then just stick em together...

<xsl:value-of select="First2digits"/><xsl:text>.</xsl:text><xsl:value-of select="lastdigit"/>

i havent checked the syntax of the above but the technique should work.

If you dont know the length of the string of numbers youll have to count em,

<xsl:value-of select="string-lenght(location/@WE)"/> which will return a number ... if you hold that string-length as a variable as above...

<xsl:variable name="lengthOffNumber"><xsl:value-of select="string-lenght(location/@WE)"/></xsl:variable>

you can then subtract 1 from it to get the second to last character of the string. You can then employ the same method to get the first numbers in the co-ords and add a . and the last digit.

If you need further assistance post your xml and xslt and ill take closer look.

MM
0
Commented:
beaten to the post!!

i think dualsoul is correct and its far easier than my method..

MM
0
Author Commented:
Ill give it a whirl.
and let you know what i find out seems simple enough on the first post.
The statement on the second post referring to if there are always 3 digits.
No there can be a few more and one less so that would not be a constant of 3 digits.

Anyways ill be back in a bit and let you guys know.
0
Author Commented:
Yes indeed it did work.
Thx for the help guys and gals.
I tried to figure this out for 2 days on my own i started out with just the xml file and had to put togeather the xsl file with no training on xml it was quite difficult that was the last problem i had on that file. Thx again all for your help.
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.