是否有任何 XQuery 代码可以将 XPath 表达式转换为业务人员可以理解的内容?

Is there any XQuery code out there to translate an XPath expression to something business people can understand?

我正在开发一个 XQuery 脚本,它采用 Schematron 规则的上下文和断言的主体来生成报告作为 excel 电子表格。

这样Schematron验证的内容才真正符合业务需求。

有人有 XPath 商务英语翻译器吗?

Xpath 就像一个地址 - 当您在页面上有很好的定位器(ID、名称或 类)时,它们会提供有用的信息。大概这就是任何人都能理解的:

//*[id='next-page-button']

//button[@class='delete-order']

但是拥有较大的相对定位符就像这样描述地址: Hey, go 2 blocks forward, turn to the right, move 3 more blocks, and 4th house after the green one is yours - 这并不容易理解,对吧?

与定位器相同 =) 即使是业务人员也会通过少量参考来理解简单的定位器,如下所示: https://data-lessons.github.io/library-webscraping/extras/xpath-cheatsheet.md.pdf

商界人士与普通人一样千差万别:例如,他们中的一些人了解基本逻辑,而另一些人则不懂。如果他们不了解基本逻辑,那么您可能就不走运了:您需要挥动双臂并画图才能与他们交流。如果他们理解基本逻辑,那么根据我的经验,他们很可能理解像

这样的 XPath 表达式
every $product in //product[exists(@discount)]
satisfies $product/@discount < 0.1 * $product/@price

如果您认为他们不会理解,那么也许您应该告诉我们您认为他们会理解的内容:因为这样我们就有了需求规范的开端。

我在寻找类似的东西:

declare function local:parse-xpath($xpath as xs:string) as xs:string
{
fn:normalize-space(
   fn:replace(
       fn:replace(
           fn:replace(
               fn:replace(
                   fn:replace(
                       fn:replace(
                           fn:replace(
                               fn:replace(
                                   fn:replace(
                                       $xpath,
                                       '\[not\(\*\)\]',
                                       ' with no child elements '
                                   ),
                                   'not\(\*\)',
                                   ' there are no child elements '
                               ),
                               '\*',
                               ' any element '
                           ),
                           '\.',
                           ' this element '
                       ),
                       '@',
                       ' attribute '
                   ),
                   '\]\[',
                   ' and '
               ),
               '\[',
               ' where '
           ),
           '\]',
           ' '
       ),
       '//',
       ' any depth where '
   )
)
};