xml - 从 for-each 中的值更改 XPath 查询

标签 xml xslt xpath

我正在尝试为每个页面上的每个操作:

<xsl:for-each select="/root/page">
   <xsl:value-of select="/root/titles/@page/"/>
</xsl:for-each>

示例 XML;

<root>
  <titles>
   <en>A title</en>
   <de>Ein Titel</de> 
 </titles>
 <page title="de">
    ....
 </page>
</root>

我遇到的问题是 XPath 未解析为 /root/titles/de/...
我怎样才能让它工作?

最佳答案

已更新

 <xsl:for-each select="/root/page">
   <xsl:variable name="language" select="@title"/>
   <xsl:value-of select="/root/titles/*[name()=$language]"/>
</xsl:for-each>

现在它对我有用了!

关于xml - 从 for-each 中的值更改 XPath 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6182712/

相关文章:

android - 当内部 View 与父级右对齐时,RelativeLayout 背景会拉伸(stretch)

xslt - 在 XSLT 中转换时间字符串

java - 将 XSL 样式表嵌入 XML

xslt - XSL - 评估条件表达式 "shortcut"吗?

python - 使用 selenium webdriver xpath 选择组合框

python - 以 UTF-8 格式从 lxml 错误日志中打印消息

c# - StringWriter.ToString() 正在破坏 xml C#

xml - XSL-FO 的架构在哪里?

xpath - 使用 xpath 和 Telegram 即时 View 提取、创建和附加

macos - 如何使用XPath和Swift 2.0解析html?