gpt4 book ai didi

xslt - 获取下一个根节点的名称及其路径的串联

转载 作者:行者123 更新时间:2023-12-03 17:27:48 25 4
gpt4 key购买 nike

我正在解析 ElasticSearch 元数据并尝试访问两个值。
鉴于此 XML:

<root>
<index1>
<mappings>
<users>
<properties>
<birthDate>
<type>date</type>
</birthDate>
<born>
<properties>
<city>
<type>text</type>
</city>
</properties>
</born>
</properties>
</users>
</mappings>
</index1>
</root>
  • 列出作为基本对象的属性子项的所有名称(没有名称“properties”的子项)很简单:
    //properties/*[not(properties)]/name()

  • 这将返回“birthDate”、“city”
  • 我尝试从上面第 1 节中的 anchor 节点获取根之前的顶部节点,在这种情况下,我尝试通过 crom“出生地”和“城市”到达“index1”。我达到的是
    ancestor::*[ancestor::root]/name()

  • 这仍然不正确
  • 我需要连接从 anchor 节点到 inode 的路径,用下划线分隔。所以,这很可能是 string-join//ancestor有一定的条件。

  • 您能否就 2) 和 3) 提出建议

    最佳答案

  • 选择倒数第二个祖先节点:$anchor//ancestor::*[last() - 1]
  • 选择所有祖先,直到倒数第二个,反向和字符串连接他们的名字:string-join(reverse($anchor//ancestor::*[position() le last() - 1]/name()), '_')
  • 关于xslt - 获取下一个根节点的名称及其路径的串联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42445217/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com