简体   繁体   English

在OSB项目中使用Xquery查找属性(使用Eclipse)

[英]Find attribute with Xquery in OSB project (using eclipse)

This is an OSB project in Eclipse. 这是Eclipse中的OSB项目。

Somewhere along a long chain of OSB processes, I have the following piece of XML, stored in $xdata: 在OSB流程的长链中,我有以下XML片段,存储在$ xdata中:

<RECORDS xmlns="url1" xmlns:xsi="url2" xmlns:schemaLocation="url3" ver="v7">
...
</RECORDS>

I want to find the value of the attribute ver . 我想找到属性ver的值。 I created the following xquery in an OSB Assign node to get the attribute: 我在OSB Assign节点中创建了以下xquery以获取属性:

$xdata/occ:RECORDS/@ver

(I created a namespace, url3, called occ in the Namespaces part of the Assign dialog.) The purpose of the Assign is of course to capture the "ver" attribute. (我在“分配”对话框的“名称空间”部分中创建了一个名为occ的名称空间url3。)“分配”的目的当然是捕获“ ver”属性。

Yet, it gets nothing, and it turns out not even the $xdata/occ:RECORDS works, it does not give the RECORDS node of the XML, it gives nothing. 但是,它什么也没得到,结果甚至$xdata/occ:RECORDS都不起作用,它没有提供XML的RECORDS节点,什么也没提供。 The only correct part is the $xdata, it gives the XML content, I checked the server log. 唯一正确的部分是$ xdata,它提供了XML内容,我检查了服务器日志。

I suspect my problem is with namespaces as that's what I'm not too confident about. 我怀疑我的问题出在命名空间上,因为那是我不太确定的事情。

The solution was pretty unexpected. 该解决方案出乎意料。 When referring to an element in a variable other than $body, you apparantly have to omit the top parent node containing the element you need. 当引用$ body以外的变量中的元素时,显然必须省略包含所需元素的顶级父节点。 In this case, you have to omit RECORDS. 在这种情况下,您必须省略RECORDS。 So the way to get the attribute is: $xdata/@ver 因此,获取属性的方法是:$ xdata / @ ver

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM