Three ways of doing this:
- Use a pipe (or other appropriate character) delimited string
...
<xsl:template match=
"Lines[contains('|John|Steve|Mark|',
concat('|', @name, '|')
)
]
">
<!-- Appropriate processing here -->
</xsl:template>
.2. Test against an externally passed parameter. If the parameter is not externally set, and we are using XSLT 1.0, the xxx:node-set()
extension function needs to be used to convert it to normal node-set, before accessing its children
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- externally-specified parameter -->
<xsl:param name="pNames">
<n>John</n>
<n>Steve</n>
<n>Mark</n>
</xsl:param>
<xsl:template match="Lines">
<xsl:if test="@name = $pNames/*">
<!-- Appropriate processing here -->
</xsl:if>
</xsl:template>
</xsl:stylesheet>
.3. In XSLT 2.0 compare against a sequence of strings
<xsl:template match="Lines[@name=('John','Steve','Mark')]">
<!-- Appropriate processing here -->
</xsl:template>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…