获得具有相同标签名称的对方的正确XPath是什么?
我试图弄清楚从此XML文档获取信息的正确XPath是什么。
<relationships>
<relationship>
<person>
<name>Jane Doe</name>
<role>Customer</role>
</person>
<person>
<name>John Doe</name>
<role>Vendor</role>
</person>
</relationship>
</relationships>
我想获得的(我正在使用PDI),是一张看起来像这样的表。
人 | 角色 | 另一个人 | 的角色 |
---|---|---|---|
Jane Doe | 客户 | John Doe | 供应商 |
John Doe | 供应商 | Jane Doe的 | 客户 |
似乎是每一个存在的关系的两行。但是由于标签共享同名名称,所以我不知道如何将交易对手添加到该行中。
先感谢您!
I am trying to figure out what the correct XPath would be to obtain information from this XML doc.
<relationships>
<relationship>
<person>
<name>Jane Doe</name>
<role>Customer</role>
</person>
<person>
<name>John Doe</name>
<role>Vendor</role>
</person>
</relationship>
</relationships>
What I would like to obtain (I'm using PDI), is a table that sort of looks like this.
Person | Role | Other Person | Other Person Role |
---|---|---|---|
Jane Doe | Customer | John Doe | Vendor |
John Doe | Vendor | Jane Doe | Customer |
Seemingly, two rows for every relationship that exists. But because tags share the same name, I don't know how to add the counterparty to the row.
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许这个例子太简单了,所以我的答案需要更多地处理您的真实数据,但我要做的是获取与人员相关的两行:
然后输入该数据流两次连接行(笛卡尔积)步骤,条件为 Role <>角色。
添加数据流两次的技巧是使用“选择值”步骤,该步骤允许您将人员和角色的列重命名为另一个人< /strong> 和另一个人角色,并且允许您将具有相同数据的两个流获取到连接中:

但是,如果您有大量数据,“连接行”步骤可能会带来性能问题,因此您可能必须寻找其他方法来实现此目的。
Probably this example is too much simplified, so my answer needs more work with your real data, but what I would do is to get the two rows related to person:
And afterwards, entry that stream of data twice to a Join rows (cartesian product) step with the condition Role <> Role.
The trick to add the stream of data twice would be to use a Select values step, that allows you to rename the columns of Person and Role to Another Person and Another person role, and will allow you to get two streams with the same data into the join:

However, the Join rows step can introduce performance issues if you have a lot of data, so maybe you'll have to look for other ways to achieve this.