Forum Stats

  • 3,836,747 Users
  • 2,262,180 Discussions


OSB: How to recreate reusable XQuery functions

303145 Member Posts: 60
edited Jun 21, 2013 4:57AM in SOA Suite Discusssions
OSB's XQuery implementation does not support the XQuery "module" which allows the creation of a function library so how can OSB provide function re-use?

I know you can create XQuery transformations that can be called but these always need a "body" that makes a specific call so I'm finiding I have to copy useful XQuery functions from one transformation to another. Ideally I should be able to call an XQuery function external to the transformation.

Does anyone have any pointers on this or is it a fundamental limitation of the OSB XQuery implementation?



  • 681888
    681888 Member Posts: 6

    i'm sorry...The Oracle Service Bus XQuery engine fully supports all of the language features that are described in the World Wide Web (W3C) specification for XQuery with one exception: modules

  • 718541
    718541 Member Posts: 1
    So how do other people avoid having to copy and paste XQuery methods from one XQuery transformation to another?
  • 671719
    671719 Member Posts: 7
    In fact another possibility i use is the following.

    Create an xquery application that you want to re-use, for example:

    Then within another XQueries (create_message) you have to use the header as an external parameter, example (ASSIGN is the assign within a OSB pipeline)

    ASSIGN $header := create_header($pars)
    ASSIGN $message := create_message($header, $otherparameters)

    This is not exactly what you want but you have created re-use and are able to unit test the xquery.
  • 303145
    303145 Member Posts: 60
    Yes that kind of helps for "course" grained functions but gets clunky when trying to be more fine grained.

    Is there any moves by the OSB development team to fully support XQuery 1.0 and the Module functionality in particular? It seems a pretty basic limitation to me and causes lots of "code duplication" that has to be maintained...
  • Alessandro I
    Alessandro I Member Posts: 34
    any plans for making it available on OSB?
  • AbhishekJ
    AbhishekJ Member Posts: 535 Silver Badge
    May be you can define custom XPath functions for fine grained utilities.
    Here is a good article on how to define custom XPath functions on OSB 11G.
  • What we did is creating a seperate project in which we use most of XQuery stuff, using SaxonSA library to run and validate the queries.

    This project adds the following possibilities for xqueries:
    - Schema validation of XPath used in XQueries (including namespaces)
    - XQuery syntax validation (with errors at the exact line and position where it fails.
    - Allows the use of modules
    - Reqression testing XQueries

    Regrettably we can not do Java callout's from XQueries as this is not supported on the ESB.

    We also build a simple 'flattener' that takes a module based, schema enriched XQuery and then generates the XQuery that can be used on the ESB itself. The flattened query is also regression tested.

    Although it was quite some work to make it, it already has paid back the initial costs of the project in the second or third project we did. We since then have enhanced the project so it also can do regression message flow validation on the OSB (we already had valid input and output messages).

    The tool also greatly improves the stability of the code on the OSB, and reduces development time as we can build the XQuery from a unit test environment that will point out typos and other xpath related problems.

    We do have some fairly complex xqueries on the OSB, the number of xqueries in the project at the moment is 187 with 250 unittests.

    So, if Oracle is not going to include it in the OSB itself (which seems lilkely at the moment), you can build such a system yourself !

    Wim Veldhuis,
    PharmaPartners BV
  • user8951048
    user8951048 Member Posts: 5
    edited Mar 1, 2013 12:16PM
    Hey mdsrobbins,

    we have exactly the same problem. OSB XQuery code reusability is close to zero.

    We have a hugh amount of transformations and unfortunaly we need to copy custom functions to all them. Nowadays our code is hard to maintain and message data enrichment is difficult to manage. We sadly need this functionality.

    I have tested to outsource our code in custom functions by Java packages. Functionality was indeed available, but live editing is not possible due to compiled Java classes. Unless these custom functions are not deployable with WLST, we will not be capable to deliver fully automated OSB deployments. Besides, versioning the JAR next to the sbconfigs takes its effort on top (every additional artefact extends versioning complexity).

    Does someone know, if the module import in OSB XQuery will be available in following releases (11g and up)?

    Many greetings
  • same question,

    Does someone know, if the module import in OSB XQuery will be available in following releases (11g and up)?

    XQuery modules are very important for us. We have a huge amount of xq ressources and copy all our functions from one to another. Very frustrating. We need module import feature in OSB.

    many greetings!

This discussion has been closed.