本文介绍了Oracle OSM-XQuery不会循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用OSM
7.2.0.3,并且我的墨盒带有Order Recognition Rule
及其Order Data Rule
(位于转换"选项卡中)
I'm using OSM
7.2.0.3 and I have cartridge with an Order Recognition Rule
, with its Order Data Rule
(inside Transformation tab)
在ODR中,我有以下XQuery代码:
In the ODR I have this XQuery code:
declare namespace im="http://xxx";
declare namespace xs="http://www.w3.org/2001/XMLSchema";
declare variable $ord := fn:root(.)/im:Order;
<_root>
<Order>
{
for $moli in $ord/MainOrderLineItem
return
$moli/LineItemAttributeInfo/LineItemAttribute
}
</Order>
</_root>
OSM的XML输入是:
The XML input to the OSM is:
<ord:CreateOrder
xmlns:ord="http://xmlns.oracle.com/communications/ordermanagement">
<im:Order xmlns:im="http://xxx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/communications/sce/dictionary/BaseOrderCommonCartridge/DataDictionary_BaseOrderCommon ../dataDictionary/DataDictionary_BaseOrderCommon.xsd">
<OrderHeader>
<OrderID>12345</OrderID>
<RevisionNumber>1</RevisionNumber>
</OrderHeader>
<MainOrderLineItem>
<LineItemAttributeInfo>
<LineItemAttribute>
<AttributeID>1234</AttributeID>
</LineItemAttribute>
</LineItemAttributeInfo>
</MainOrderLineItem>
<MainOrderLineItem>
<LineItemAttributeInfo>
<LineItemAttribute>
<AttributeID>5678</AttributeID>
</LineItemAttribute>
</LineItemAttributeInfo>
</MainOrderLineItem>
<MainOrderLineItem>
<LineItemAttributeInfo>
<LineItemAttribute>
<AttributeID>abcd</AttributeID>
</LineItemAttribute>
</LineItemAttributeInfo>
</MainOrderLineItem>
</im:Order>
</ord:CreateOrder>
<MainOrderLineItem>
出现3次,但输出仅为1:
There are 3 occurences of <MainOrderLineItem>
's but the output is only 1:
<LineItemAttribute xmlns:im="http://xxx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AttributeID>1234</AttributeID>
</LineItemAttributeInfo>
为什么不循环?
非常感谢您的答复.
推荐答案
我刚刚使用了您的XQuery并进行了检查,就可以了.尝试在控制台中打印$ ord变量,以查看OSM中实际得到的内容.
I just used your XQuery and checked, it is fine. Try to print out the $ord variable in console to see what you are actually getting in OSM.
这是我在任何XQuery ide中尝试过的方法:
this is what I tried in any XQuery ide:
declare namespace im="http://xxx";
declare variable $ord1 := <ord:CreateOrder
xmlns:ord="http://xmlns.oracle.com/communications/ordermanagement">
<im:Order xmlns:im="http://xxx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/communications/sce/dictionary/BaseOrderCommonCartridge/DataDictionary_BaseOrderCommon ../dataDictionary/DataDictionary_BaseOrderCommon.xsd">
<OrderHeader>
<OrderID>12345</OrderID>
<RevisionNumber>1</RevisionNumber>
</OrderHeader>
<MainOrderLineItem>
<LineItemAttributeInfo>
<LineItemAttribute>
<AttributeID>1234</AttributeID>
</LineItemAttribute>
</LineItemAttributeInfo>
</MainOrderLineItem>
<MainOrderLineItem>
<LineItemAttributeInfo>
<LineItemAttribute>
<AttributeID>5678</AttributeID>
</LineItemAttribute>
</LineItemAttributeInfo>
</MainOrderLineItem>
<MainOrderLineItem>
<LineItemAttributeInfo>
<LineItemAttribute>
<AttributeID>abcd</AttributeID>
</LineItemAttribute>
</LineItemAttributeInfo>
</MainOrderLineItem>
</im:Order>
</ord:CreateOrder>;
let $ord := $ord1/im:Order
return
(
for $moli in $ord/MainOrderLineItem
return
$moli/LineItemAttributeInfo/LineItemAttribute
)
结果仅是预期的.
<LineItemAttribute xmlns:im="http://xxx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ord="http://xmlns.oracle.com/communications/ordermanagement">
<AttributeID>1234</AttributeID>
</LineItemAttribute>
<LineItemAttribute xmlns:im="http://xxx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ord="http://xmlns.oracle.com/communications/ordermanagement">
<AttributeID>5678</AttributeID>
</LineItemAttribute>
<LineItemAttribute xmlns:im="http://xxx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ord="http://xmlns.oracle.com/communications/ordermanagement">
<AttributeID>abcd</AttributeID>
</LineItemAttribute>
这篇关于Oracle OSM-XQuery不会循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!