xslt:匹配部分属性名称 [英] xslt: match partial attribute name

查看:33
本文介绍了xslt:匹配部分属性名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何 xslt 版本都可以.

any xslt version should do.

假设这样的属性:

<tag attr-something="1" attr-something-else="1" attr-something-more="1" attr-different="1" attr-thing="1">

匹配名称以 attr-something 开头的所有属性的最简单方法是什么?

what's the simplest way to match all attributes whose names start with attr-something ?

这匹配一个特定的属性:

this matches one specific attribute :

<xsl:template match="@attr-something"/>

这匹配硬编码的属性列表:

this matches a hardcoded list of attributes :

<xsl:template match="@attr-something|@attr-something-else"/>

这匹配包含以所需字符串开头的属性[s]的所有节点:

this matches all nodes that contain attribute[s] that start with the required string :

<xsl:template match="*[starts-with(name(@*), 'attr-something')]"/>

但是如何匹配属性本身?

but how to match attributes themselves ?

推荐答案

要通过部分名称匹配属性,您可以使用:

To match attributes by a partial name you can use:

<xsl:template match="@*[starts-with(name(), 'attr-something')]"> ...

这篇关于xslt:匹配部分属性名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆