获得具有相同标签名称的对方的正确XPath是什么?

发布于 2025-01-19 11:00:14 字数 813 浏览 5 评论 0原文

我试图弄清楚从此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.

PersonRoleOther PersonOther Person Role
Jane DoeCustomerJohn DoeVendor
John DoeVendorJane DoeCustomer

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呆° 2025-01-26 11:00:14

也许这个例子太简单了,所以我的答案需要更多地处理您的真实数据,但我要做的是获取与人员相关的两行:

人员角色
Jane DoeCustomer
John DoeVendor

然后输入该数据流两次连接行(笛卡尔积)步骤,条件为 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:

PersonRole
Jane DoeCustomer
John DoeVendor

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:
How to input a stream of data twice

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文