Tuesday, June 7, 2011

fn-bea:inlinedXML

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;

xf:myXQ($string1)



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



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


the result is asdf


1 comment:

Unknown said...

Dear Team,
I am trying to call fn-bea:inlinedXML, but i am getting the below error. Could you please help.
Error:
Static error on line 33 column 59
XPST0017 Cannot find a 1-argument function named Q{oracle.xquery.XQueryContext}inlinedXML()
2021-06-25 12:29:28.046 ERROR 796 --- [ntContainer#0-1] c.p.b.f.c.FitRoutingConsumer : Error while calling transformBtpsgenXquery : net.sf.saxon.s9api.SaxonApiException: Cannot find a 1-argument function named Q{oracle.xquery.XQueryContext}inlinedXML()