作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个具有相同匹配模式的键。图案很长。模式本身并不重要;问题是冗长的重复:
<xsl:key name="narrow-things-by-columnset" match="p | p-cont |
heading[not(parent::section or parent::contents) and not(parent::p)] |
language-desc | country-desc | graphic[not(parent::section or parent::contents)] |
block-quote | bulleted-list | blank-line |
bibliography | language-name-index | language-code-index | country-index | table-of-contents"
use="sileth:columnset-id(.)"/>
<!-- TODO: DRY: I would love to be able to share the above match pattern instead of
duplicating it. -->
<xsl:key name="narrow-things-by-section" match="p | p-cont |
heading[not(parent::section or parent::contents) and not(parent::p)] |
language-desc | country-desc | graphic[not(parent::section or parent::contents)] |
block-quote | bulleted-list | blank-line |
bibliography | language-name-index | language-code-index | country-index | table-of-contents"
use="sileth:section-id(.)"/>
最佳答案
我会用模式定义一个通用实体,并从两个位置引用它。所以样式表将开始
<!DOCTYPE xsl:stylesheet [
<!ENTITY match-elements "p | p-cont
| heading[not(parent::section or parent::contents)
and not(parent::p)]
| language-desc | country-desc
| graphic[not(parent::section or parent::contents)]
| block-quote | bulleted-list | blank-line
| bibliography | language-name-index | language-code-index
| country-index | table-of-contents">
]>
<xsl:stylesheet ...>
...
<xsl:key name="narrow-things-by-columnset"
match="&match-elements;"
use="sileth:columnset-id(.)"/>
<!-- DONE: DRY: Isn't is nice to be able to share the above
match pattern instead of duplicating it?
Hooray for general entities! -->
<xsl:key name="narrow-things-by-section"
match="&match-elements;"
use="sileth:section-id(.)"/>
关于xslt - 如何在键之间共享匹配模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17244436/
我是一名优秀的程序员,十分优秀!