Cornacap Posted February 2, 2009 Share Posted February 2, 2009 Hi to all,I'm just trying out the features of xQuery for my needs. So far it worked brilliant (extracting the the Name, some attributes and UTM-coodinates out of an XML-database with about 10.000 entrys).Here's what I used so far: <results>{for $x in doc("-the URL-")/result/objectwhere $x/@cat=5order by $x/@idreturn<utm>w,utm,{data($x/@id)},33U,{data($x/coords/@x)},{data($x/coords/@y)},{data($x/@cat)},{data($x/@reg)},{data($x/@dis)},{data($x/@dep)}</utm>}</results> My problem lies on attributes of the elements 'coords'.First: in the database the x-coords are stored with 7 numbers (a specific German way to notice the first part of UTM-coordinates for maps), e.g. 3368038. But I would like to write it originally – with 6 numbers. Means I have to delete the first number at the beginning ('3'). So I tried to subtract with 3000000 ({data($x/coords/@x-3000000)}). It ended up with any result.My first question is: Is there a way to eleminate this first number??Second Problem:Some x-/y-coords are decimals (e.g. 3366733.25). I'd like to eleminate all decimals so I tried out the function 'round' ({round($x/coords/@x)}). It worked. Ok. But the way of writing the numbers was changed to the scientific way (?) (3.366733E6 instead of 3366733). Well, no problem to read it for myself, but not the program I'll use to recalculate the coordinates.So, how could achieve it to see the original numbers just without the decimals?I appreciate any help on this,Cornal Link to comment Share on other sites More sharing options...
Cornacap Posted February 5, 2009 Author Share Posted February 5, 2009 Found the answer for the second problem on my own: changing type from double to decimals.so instead of {round($x/coords/@x)} I just write: {round($x/coords/@x) cast as xs:decimal} Still looking for an answer to my first question: how to eleminate the first number of the x-coordinate? Link to comment Share on other sites More sharing options...
Cornacap Posted February 5, 2009 Author Share Posted February 5, 2009 Now I played a little, to solve the first question. This one works: {round($x/coords/@x)-3000000 cast as xs:decimal} So everything is fine. But nevertheless I'm rather new to Xquery: would you've done it in another way - possibly simpler? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.