XSL 修改 html 的 href 属性标签
我对 XSLT 相当陌生,想知道如何使用从 XML 节点获取的值修改标签的 href 属性。
特别是,我的 XML 文件是这样的
<root>
<privileges edit="1" del="1"></privileges>
<rooms>
<room>
<id>1</id>
<roomNr>101</roomNr>
<locked>0</locked>
<lockdownReason></lockdownReason>
</room>
</rooms>
</root>
,我的 XSL 文件是这样的,
<xsl:for-each select="root/rooms/room">
<div class="column toolbox">
<xsl:if test="$edit = 1">
<a href='admin.php?room=VALUE_OF_ID__OF_CURRENTLY_SELECTED_NODE'>this is a link</a>
<p>edit is true</p>
</xsl:if>
</div>
<div class="column">Room Nr.:<xsl:value-of select="roomNr"/></div>
</xsl:for-each>
大写字母表明了我试图完成的任务。 请有人好心回复一下。 谢谢
I am rather new to XSLT and was wondering how I can modify the href attribute of a tag with a value acquired from an XML node.
In particular, my XML file goes like this
<root>
<privileges edit="1" del="1"></privileges>
<rooms>
<room>
<id>1</id>
<roomNr>101</roomNr>
<locked>0</locked>
<lockdownReason></lockdownReason>
</room>
</rooms>
</root>
and my XSL file goes like
<xsl:for-each select="root/rooms/room">
<div class="column toolbox">
<xsl:if test="$edit = 1">
<a href='admin.php?room=VALUE_OF_ID__OF_CURRENTLY_SELECTED_NODE'>this is a link</a>
<p>edit is true</p>
</xsl:if>
</div>
<div class="column">Room Nr.:<xsl:value-of select="roomNr"/></div>
</xsl:for-each>
the capital letters indicate what I try to accomplish.
Someone please be kind enough to reply.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于 XSLT,最简单的方法是使用 属性值模板 (AVT ) 并选择
的值,如下所示:For your XSLT, the easiest thing would be to use an Attribute Value Template (AVT) and select the value of
<id>
, like this:您正在寻找 xsl:attribute。我不太确定对当前
id
的引用应该是什么样子,但是这样的事情应该可以帮助您开始:You're looking for xsl:attribute. I'm not really sure about how the reference to the current
id
should look, but something like this should get you started: