问题标签 [xpath-3.0]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
153 浏览

xml - 如何使用批量模式在 mule 中插入数据库以进行 XML 输入

我已输入 XML 作为有效负载,我想使用批量模式将 XML 值插入到数据库列中。Mule 文档显示批量插入只能使用集合完成。如果可以通过实现集合来完成,我们如何将 xml 转换为集合,然后进行批量插入而不是耗时的 For-each 循环。

使用的骡版本 - v3.8

让我们在下面取样,

示例 XML 作为有效负载输入,

请回答以下两个问题, 1. 如何将此输入的 XML 转换为集合?2. 如何用问题1创建的集合实现批量插入?

0 投票
2 回答
212 浏览

datetime - Xpath 中的循环时间

在 XPath 中舍入时间和日期时间的最简单和正确的方法是什么?

例如,如何以local:round-time-to-minutes以下测试用例的方式定义函数:

将返回"12:59:00"。不确定在“23:59:31”的情况下哪个更好——返回“00:00:00”或引发动态错误。

还有类似的函数local:round-datetime-to-minutes来处理日期时间?(它没有像上面这样的边缘情况)

让这些函数使用“向正无穷大的一半”规则,其中一半是 30.0 秒。

0 投票
1 回答
70 浏览

xslt - xslt:进行否定选择的最简单方法是什么?

基本上我想要的是这样的东西,它可以找到所有无法查找 ID 的节点(“断开的链接”):

但这并没有按预期工作 - 我想语法是错误的,正确的方法应该是什么?

0 投票
2 回答
112 浏览

xpath - XPath 表达式来访问字符串的每个元素

这个问题听起来很基础;但是,我一直在尝试找到一些与之相关的资源。

假设有一系列字符或字符串:

上面的查询会给我一个序列的各个元素。

但是,如果我只有一个字符串,如何检索它的每个元素?

如何从中获取“a” $abc,有没有$abc[0]这样的做法?

0 投票
1 回答
47 浏览

xpath - 用于计算节点数组上的算术的 XPath 表达式

问题陈述:如何为这两种情况编写高效的 XPath 表达式?

如果任何节点的值非零,我需要检查前一个和下一个节点的特定子节点的值是否非零。即如果 node_50/value_50_0 不为零,则 node49/value_49_0 和 node51/value_51_0 也应该不为零。同样,对于其他情况。

接下来,它应该将备用节点的值相加。即 node_1/value_1_0 + node_3/value_1_0 + ... + node_63/value_1_0。同样,对于 value_1_1,...,value_63_1 等等。

我想知道是否有为每个索引提供计数器变量的任何“for 循环”,以便 XPath 表达式对于这两种情况都很简单?

伪代码:

0 投票
2 回答
54 浏览

xpath - Faster XPath expressions to execute queries from multiple XMLs

I have the two following XMLs and the problem statement is as follows.

  1. Parse XML 1 and if subnode of any node_x contains 'a' in its name (like in value_a_0) and value_a_0 contains a specific number, parse XML 2 and go to node_x-1 for all abc_x in and compare the content of value_x-1_0/1/2/3 with certain entities.

  2. If subnode of any node_x contains 'b' in its name (like in value_b_0) and value_b_0 contains a specific number(say 'm'), parse XML 2 and go to node_x+1 for all abc_x in and compare the content of value_x-1_0/1/2/3 with 'm'.

Example : For all the value_a_0 in record1 check if value_a_0 node contains 5. If so, which are the case for node_1 and node_9, go to record2/node_0 and record2/node_8 and compare the contents of value_0_0/1/2/3 whether they contains 5 or not. Similarly, for rest of the cases.

I was wondering what would be the best practice to solve it? Is there any hash-table approach in Xpath 3.0?

First XML

Second XML

0 投票
2 回答
238 浏览

xml - 平面结构中的 XPath 递归“父”选择

给出了以下 XML:

现在,我想为例如元素 3 选择所有“父”节点。假设元素 3 的所需输出应该是:

  • 元素 1
  • 元素 2

元素 2 的期望输出应该是:

  • 元素 1

元素 6 的期望输出应该是

  • 要素 5
  • 元素 2
  • 元素 1

这甚至可以用 XPath 实现吗?如果是,你怎么能做到?

0 投票
1 回答
35 浏览

xpath - 这个 xpath 的确切含义

我遇到了这个 XPath 字符串...

courses[?(@.id==101)].students[?(@.id==111)]

我什至不确定它是否是有效的 XPath,因为“?” 和 '。' 被使用。而且它在许多在线 XPath 评估器中不起作用。

虽然,在 XPath 3 中,有一个查找运算符 ('?') 和一些 JSON 扫描功能。参考:https ://www.altova.com/training/xpath3/xpath-31#lookup-operator

所以,我想知道'?()'和'。是。

到目前为止,我猜测这个表达式被用来搜索 XML 中的 JSON 内容。

猜测 JSON 对象是这样的:

简而言之,它是一个有效的 XPath 3 表达式吗?如果是,那么“?()”和“。”到底是什么?正在做?

0 投票
3 回答
60 浏览

regex - 使用 match() 匹配特定的正则表达式

尝试使用 match() 匹配特定单词

例子:

任何与“Xander”字词完全匹配的实例都是目标。

0 投票
1 回答
60 浏览

xml - 划分一组项 XPath

我是 XPath 的新手,所以不太了解。我一直在谷歌搜索,找不到任何东西,也许我只是在搜索错误的东西,但我想我会在这里问。

我目前正在尝试divide一个set of numbers,,(100, 200, 300)全部由same value。所以我想要:100/2, 200/2, 300/2。我最初认为它会类似于: //products/price div 2,但这会尝试divide将实际设置为 2 而不是 items

我该怎么做呢?谢谢