source: TI07-MOLES/trunk/xqueryLib/Utilities/inputParse_xquery_lib.xquery @ 2143

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI07-MOLES/trunk/xqueryLib/Utilities/inputParse_xquery_lib.xquery@2143
Revision 2143, 828 bytes checked in by ko23, 15 years ago (diff)

Intermediate update

Line 
1module namespace inputParse='http://ndg.nerc.ac.uk/xquery/lib/inputParse';
2
3declare function inputParse:fix-coord($e as element()) as element()
4(: Parse a non-decimal co-ordinate element,  parse to see if it's possible to convert to
5a decimal co-ordinate, and do so, else return the rubbish provided :)
6{
7if ($e castable as xs:decimal) then 
8$e
9else
10let $value := substring(data($e), 1, string-length($e)-1)
11let $point := lower-case(data($e))
12return
13if ($value  castable as xs:decimal) then 
14if (ends-with($point, 'n')) then
15element {name($e)} {$value}
16else if (ends-with($point, 's')) then
17element {name($e)} {concat('-', $value)}
18else if (ends-with($point, 'e')) then
19element {name($e)} {$value}
20else if (ends-with($point, 'w')) then
21element {name($e)} {concat('-', $value)}
22else $e
23else  $e
24} ;
Note: See TracBrowser for help on using the repository browser.