gpt4 book ai didi

xml - xslt 转换中表达式 '[' 中的意外标记

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

所以,我的 xml 看起来像这样:

<Document Resolution="{X=300,Y=300}">
...
</Document>

我正在尝试生成 xml与那些分辨率值。它应该如下所示:
<image xdpi="300" ydpi="300">
...
</image>

现在,我的 xslt文件看起来像这样(图像部分):
<image>
<xsl:attribute name="xdpi">
<xsl:value-of select="/*/[substring-before(substring-after(@Resolution, 'X='), ',')]"/>
</xsl:attribute>
....
</image>

我正在尝试提取 X分辨率的值。但是,这是我收到的消息:

Unexpected token in the expression '['



我尝试删除方括号,但提示变得更糟。

有解决办法吗?或另一种提取分辨率值的方法?

谢谢

最佳答案

只需使用

<xsl:template match="Document">
<image xdpi="{substring-before(substring-after(@Resolution, 'X='), ',')}" ydpi="{...}">...</image>
</xsl:template>

对于您的方法,您需要
<xsl:value-of select="substring-before(substring-after(/*/@Resolution, 'X='), ',')"/>

关于xml - xslt 转换中表达式 '[' 中的意外标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46247173/

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