xml – XSLT – 有没有办法追加添加的属性?
发布时间:2020-12-16 23:50:27 所属栏目:百科 来源:网络整理
导读:简化示例: xsl:template name="helper" xsl:attribute name="myattr"first calculated value/xsl:attribute/xsl:templatexsl:template match="/ myelem xsl:call-template name="helper" / xsl:attribute name="myattr"second calculated value/xsl:attribu
简化示例:
<xsl:template name="helper"> <xsl:attribute name="myattr">first calculated value</xsl:attribute> </xsl:template> <xsl:template match="/> <myelem> <xsl:call-template name="helper" /> <xsl:attribute name="myattr">second calculated value</xsl:attribute> </myelem> </xsl:template> 有没有办法让第二个将第二个计算值附加到结果节点中的同一个myattr属性? 我已经看到如果目标属性在源xml中,可以使用属性值模板,但是我可以以某种方式引用我之前附加到结果节点的属性的值吗? 提前致谢!
您可以采取的一种方法是向助手模板添加一个参数,该参数将附加到属性值.
<xsl:template name="helper"> <xsl:param name="extra" /> <xsl:attribute name="myattr">first calculated value<xsl:value-of select="$extra" /></xsl:attribute> </xsl:template> 然后您可以将第二个计算值作为参数过去 <xsl:template match="/> <myelem> <xsl:call-template name="helper"> <xsl:with-param name="extra">second calculated value</xsl:with-param> </xsl:call-template> </myelem> </xsl:template> 您不必为每次调用设置参数.如果您不想要任何附加内容,只需调用没有参数的帮助器模板,并且不会向第一个计算值附加任何内容. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- xcode – 在Playground的“SupportCode.swift”中导入第三方
- group by语句,聚合函数与其他语句(关系,执行过程)
- 如何在Swift 2.2中编写非C类for循环?
- 关联--依赖、组合--聚合 联系与区别:
- 温故知新: 正则表达式简记
- Cocos Code IDE 开发Lua和Cocos2d-x3.2配置篇(可能是最新的
- c# – 有什么方法可以在订阅某个活动/代表时收到通知?
- IEEE 802.3ad 链路聚合与LACP的简单知识&EtherChannel
- SAX进行实体解析XML(android)
- 基于Flex / Flash的应用程序是否容易受到XSS攻击?这种攻击