[xquery-talk] static error [err:XPST0051]: "xs:anySimpleType": not defined as atomic type

Robby Pelssers robby.pelssers at nxp.com
Wed Dec 19 06:21:21 PST 2012


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