TheTinkeringToad
asked on
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:val ue-of select="format-number(numb er(locatio n/@NS),'#, N;#,S')" /></td>
<td bgcolor="#ffffff"><xsl:val ue-of select="format-number(numb er(locatio n/@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.
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:val
<td bgcolor="#ffffff"><xsl:val
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
beaten to the post!!
i think dualsoul is correct and its far easier than my method..
MM
i think dualsoul is correct and its far easier than my method..
MM
ASKER
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.
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.
ASKER
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.
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.
<!-- this selects the whole string eg 575 -->
<xsl:variable name="wholeNumber"><xsl:va
<!-- this selects only the first 2 digits start at the first value (5) and select 2 digits -->
<xsl:variable name="First2digits"><xsl:v
<!-- this selects only the 3rd digit: start at the second value (7) and select 1 digits -->
<xsl:variable name="lastdigit"><xsl:valu
then just stick em together...
<xsl:value-of select="First2digits"/><xs
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(loca
<xsl:variable name="lengthOffNumber"><xs
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