[xquery-talk] static error [err:XPST0051]: "xs:anySimpleType": not defined as atomic type
Robby Pelssers
robby.pelssers at nxp.com
Wed Dec 19 06:54:28 PST 2012
Ok...
I managed to get something working. But not sure if it is such a smart idea... Any comments from the experts?
http://robbypelssers.blogspot.nl/2012/12/using-options-in-xquery.html
Cheers,
Robby
-----Original Message-----
From: Robby Pelssers
Sent: Wednesday, December 19, 2012 3:21 PM
To: talk at x-query.com; Robby Pelssers
Subject: static error [err:XPST0051]: "xs:anySimpleType": not defined as atomic type
Hi all,
I was experimenting a bit to make my code more robust but I don't fully understand why the code below complains about the local:getOrElse function.
Can someone shed some light on this matter?
Thx in advance,
Robby
(:
Taken the same approach as Scala we return options which are either none or some
<option>
<none/>
</option>
<option>
<some>4</some>
</option>
Example of a lookup map represented in XML
<map>
<entry key="PH3330L">SOT669</entry>
<entry key="BUK100-50GL">SOT78B</entry>
<entry key="PSMN003-30B">SOT404</entry>
</map>
:)
declare function local:getOrElse($map as element(map), $key as xs:string, $else as xs:anySimpleType) as xs:anySimpleType {
let $option := local:get($map, $key)
return (if (empty($option/some)) then $else else data($option/some)) };
declare function local:get($map as element(map), $key as xs:string) as element(option) {
return (if (empty($map/entry[key=$key])) then <option><none/></option> else <option><some>{data($map/entry[key=$key])}</some></option>)
};
let $map :=
<map>
<entry key="PH3330L">SOT669</entry>
<entry key="BUK100-50GL">SOT78B</entry>
<entry key="PSMN003-30B">SOT404</entry>
</map>
return
<lookups>
<lookup>{local:getOrElse($map, "PH3330L", "test1")}</lookup>
<lookup>{local:getOrElse($map, "INVALID", "test1")}</lookup>
</lookups>
More information about the talk
mailing list