Tuesday, June 7, 2011


If you want to manipulate XML in a XQuery as a string, and then return it to OSB as an element, you need to explicitly convert it to an XMLObject using fn-bea:inlinedXML().
Make sure that your XML string is self sufficient, with all the namespace declaration, because inlinedXML() cannot access the globally declared namespaces (even those internal to OSB, like ctx).

xquery version "1.0" encoding "Cp1252";
(:: pragma  type="xs:anyType" ::)

declare namespace xf = "http://tempuri.org/OSB%20Project%201/myXQ/";
declare namespace ctx = "http://www.bea.com/wli/sb/context";

declare function xf:myXQ($string1 as xs:string)
    as element(*) {
        let $myXMLASString := 'ciao'
       return fn-bea:inlinedXML($myXMLASString)        

declare variable $string1 as xs:string external;


Incidentally, inlinedXML can be also used to turn < into < :

let $a := <c>asdf</c>
return fn-bea:inlinedXML($a)

the result is asdf

No comments: