Subject: Re: [xsl] Need an elegant (succinct) XPath expression to decode a 3-character field From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 26 Jan 2024 15:15:20 -0000 |
Hi Folks,
My XML document contains an element named RNP (Required Navigation
Performance, which is the required performance of an aircraft, measured in nautical miles).
decimal point, the last digit.
Its value is three digits, e.g.,
<RNP>152</RNP>
The value is encoded. I need an XPath expression which decodes it.
If the first digit is non-zero, then the decoding is: the first two digits,
the number of places to the right of the decimal point, e.g.,
In the example above, the first digit is 1, so it is decoded to 15.2
152 -> decode -> 15.2
(the aircraft's required performance is 15.2 NM).
If the first digit is zero, then the decoding is: the third digit represents
010 -> decode -> 1 011 -> decode -> 0.1 012 -> decode -> 0.01 013 -> decode -> 0.001 014 -> decode -> 0.0001 015 -> decode -> 0.00001 016 -> decode -> 0.000001 017 -> decode -> 0.0000001 018 -> decode -> 0.00000001 019 -> decode -> 0.000000001
B if (starts-with(., '0')) then xs:integer(substring(., 1, 2)) div math:pow(10, xs:integer(substring(., 3))) else . div 10
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Need an elegant (succinct) XP, Roger L Costello cos | Thread | Re: [xsl] Need an elegant (succinct, Michael Kay mike@xxx |
[xsl] Need an elegant (succinct) XP, Roger L Costello cos | Date | Re: [xsl] Need an elegant (succinct, Michael Kay mike@xxx |
Month |