OSB fn:bea Function using XQuery Engine in Java

1.1k Views Asked by At

After some research I haven't found a solution, but quite alot of people with this problem:

I am trying to do a XQuery Transformation in a Java Application using

net.sf.saxon.s9api

However I get this error when trying to compile XQueryExecutable exec = compiler.compile(...)); my XQuery:

    Error on line 13 column 3 of AivPumaRequest.xquery:
  XPST0081 XQuery static error near #... fn-bea:inlinedXML(fn:concat#:
    Prefix fn-bea has not been declared
Error on line 44 column 102 of AivPumaRequest.xquery:
  XPST0081 XQuery static error near #... div xdt:dayTimeDuration('P1D'#:
    Prefix xdt has not been declared
Error on line 199 column 3 of AivPumaRequest.xquery:
  XPST0081 XQuery static error near #... fn-bea:inlinedXML(fn:concat#:
    Prefix fn-bea has not been declared
Error on line 282 column 4 of AivPumaRequest.xquery:
  XPST0081 XQuery static error near #... {fn-bea:inlinedXML(fn:concat#:
    Prefix fn-bea has not been declared

net.sf.saxon.s9api.SaxonApiException: Prefix fn-bea has not been declared

Is there a way to static include this prefix or what am I missing so my XQuery Engine (SAXON) finds the Prefix?

1

There are 1 best solutions below

0
Michael Kay On

The simple answer to your question is that you can declare namespace prefixes either within the query prolog using

declare namespace fn-bea = "http://some-appropriate-uri";

or in the Saxon API using

XQueryCompiler.declareNamespace("fn-bea", "http://some-appropriate-uri")

But this won't get you any further unless (a) you know what URI to bind the prefixes to, and (b) you make the functions with these names available to the query processor.

The reference to xdt:dayTimeDuration suggests to me that this query was written when XQuery was still a working draft. If you look at the 2005 working draft, for example

https://www.w3.org/TR/2005/CR-xquery-20051103/

you'll see in section 2 that it uses a built-in prefix

xdt = http://www.w3.org/2005/xpath-datatypes

By the time XQuery 1.0 became a recommendation, the dayTimeDuration data type had been moved into the standard XML Schema (xs) namespace, so you can probably simply replace "xdt" by "xs" - though you should be aware that the semantics of the language probably changed in minor details as well.

As for fn-bea:inlinedXML, the choice of prefix suggests to me that this was probably a built-in vendor extension in the BEA query processor, which was taken over by Oracle. The spec here:

https://docs.oracle.com/cd/E13162_01/odsi/docs10gr3/xquery/extensions.html

says:

fn-bea:inlinedXML Parses textual XML and returns an instance of the XQuery 1.0 Data Model.

Which suggests that the function does something very similar to the XQuery 3.0 function fn:parse-xml(), and I suggest you try making that replacement in your query.