连接 XSL 中的节点并将值放入 HTML“标题”中属性
我的 XML 数据格式如下:
<Parent>
<Child>Value1</Child>
<Child>Value2</Child>
<Child>Value3</Child>
.
.
.
</Parent>
我必须将封闭标记的 HTML title
属性设置为连接值,类似于:
<xsl:attribute name="title">Value1,Value2,Value3,.,.,.</xsl:attribute>
我检查了之前在 SO 上提出的问题,但大多数解决方案是多行,(并且是 XSL 新手)我认为我不能在
标记中包含多行代码。这件事该怎么办呢?
I have XML data in a form like:
<Parent>
<Child>Value1</Child>
<Child>Value2</Child>
<Child>Value3</Child>
.
.
.
</Parent>
I have to set the HTML title
attribute of the enclosing tag to the concatenated values, something like:
<xsl:attribute name="title">Value1,Value2,Value3,.,.,.</xsl:attribute>
I checked questions asked previously on SO, but most of the solutions were multiline, (and being new to XSL) I think that it i can't include the multiline code within my <xsl:attribute></xsl:attribute>
tags. How to go about this thing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
XSLT 2.0 解决方案:
当此转换应用于提供的 XML 文档时:
生成所需的正确结果:
或者,如果人们想要覆盖身份规则以获得更大的灵活性:
当此转换应用于同一个 XML 文档(上面)时,会再次生成相同的所需正确结果:
XSLT 2.0 solution:
When this transformation is applied on the provided XML document:
the wanted, correct result is produced:
Or, if one wants to override the identity rule for greater flexibility:
When this transformation is applied on the same XML document (above), the same wanted, correct result is produced again:
我对xsl了解不多,但是xsl中有一个xpath函数string-join可以使用,这样可以减少行数。我通常在 Orbeon Xforms 中使用此功能。
参考:http://www.w3schools.com/xpath/xpath_functions.asp
I dont know much about xsl, but there is a xpath function string-join which can be used may be in the xsl so that number of lines can be reduced. I usually use this function in Orbeon Xforms.
Reference: http://www.w3schools.com/xpath/xpath_functions.asp