[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How to fuzz the last four digits of a lat/long?

Subject: How to fuzz the last four digits of a lat/long?
From: "Roger L Costello costello@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 22 May 2021 13:09:38 -0000
 How to fuzz the last four digits of a lat/long?
Hi Folks,

I want to transform this location data:

<location>
    <altitude>30000</altitude>
    <latitude>42.364978</latitude>
    <longitude>-71.022362</longitude>
</location>

to this:

<location>
    <altitude>30000</altitude>
    <latitude>42.360000</latitude>
    <longitude>-71.020000</longitude>
</location>

That is, I want to map the altitude value directly and for the latitude and
longitude values I want to fuzz them by setting their last four digits to
zero.

I can do the latitude transformation in two steps:

1. Use format-number() to truncate the number to two digits to the right of
the decimal point.

2. Use concat() to append '0000'.

That is:

<latitude>
    <xsl:value-of select="concat(format-number(latitude, '0.00'), '0000')" />
</latitude>

But, but, but, ....

I really want to do the transformation in one step. Is there a way to do the
transformation in one step (using the built-in XSLT or XPath functions)? As
best I can tell, I can't do it in one step using the format-number() function,
right?

Ditto for the longitude transformation.

/Roger

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.