2014-09-10 44 views
1

在Weblogic Service Bus 10g中,我有一個XQuery文件,其中包含一個函數,我希望在另一個XQuery文件的函數中使用該函數。我如何在OSB中實現這一點?Weblogic OSB - 從另一個XQuery文件中調用函數

項目/了projectA/getMessageType的XQuery:

declare namespace xf = "http://tempuri.org/projectA/getMessageType/"; 

declare function xf:getMessageType($anyType as element()) 
    as xs:string { 

    ... 
}; 

declare variable $anyType as element() external; 

xf:getMessageType($anyType) 

項目/項目B /進程的XQuery:

declare namespace xf = "http://tempuri.org/projectB/process/"; 

declare function xf:process($data as element()) 
    as element() { 

    // call projectA's getMessageType($data) here!!! 
    ... 
}; 

由於提前, PM

回答

2

您將需要發揮xf:getMessageType功能從projectA變成庫模塊,相反到主模塊。然後您可以導入庫模塊。

考慮是這樣的:

項目/了projectA/getMessageType的XQuery:

import module namespace common = "http://your.site.com/common"; 

declare namespace xf = "http://tempuri.org/projectA/getMessageType/"; 
declare variable $anyType as element() external; 

common:getMessageType($anyType) 

項目/項目B /過程的XQuery:

import module namespace common = "http://your.site.com/common"; 

declare namespace xf = "http://tempuri.org/projectB/process/"; 

declare function xf:process($data as element()) 
    as element() { 

    common:getMessageType(data) 
    ... 
}; 

項目/通用/ common.xqy

module namespace common = "http://your.site.com/common"; 

declare function common:getMessageType($anyType as element()) 
    as xs:string { 

    ... 
}; 

您可能需要將at語句添加到import module語句中,指定公用庫模塊的文件位置,但我不確定WebLogic OSB中的內容如何。

+1

嗨,亞當,謝謝你的回答。你是絕對正確的,把函數放入一個庫模塊就可以做到。我只是想知道是否可以直接導入另一個XQuery文件的功能,因爲這個要求是針對僅處於維護模式並且正在被逐步淘汰的系統中的小更新(因此想要沒有創建一個模塊並更新每個流程來代替它)。 – 2014-09-16 10:26:27

+1

不用擔心,XQuery規範指出你只能從'library module'中導入函數,而不能從'main module'中導入。 – adamretter 2014-09-21 16:51:05

相關問題