Ollie Williams
Ollie Williams

Reputation: 2494

XSLT match not multiple conditions

I have the following xslt:

   <xsl:template match="DataObject[not(ends-with(@FileRef, '.cif'))]" mode="compound_links">
        <xsl:variable name="link" select="./@FileRef"/>
        <xsl:text> | </xsl:text><a data-test="compound-data-file-link">
            <xsl:attribute name="href" select="func:imgUrl('original', $link)"/>
            <xsl:apply-templates select="ancestor::DefinitionListEntry/Term" mode="markup"/></a>
    </xsl:template>

I need to extend the match condition so that it will not select .cif files or .fcf files. At the moment it is only excluding .cif files.

Upvotes: 1

Views: 1433

Answers (1)

Tim C
Tim C

Reputation: 70598

Try this template match....

<xsl:template match="DataObject[not(ends-with(@FileRef, '.cif') or ends-with(@FileRef, '.fcf'))]" mode="compound_links">

Alternatively, as you must be using XSLT 2.0 for ends-with to work, you could use regular expressions instead, with matches

<xsl:template match="DataObject[not(matches(@FileRef, '.*\.(cif|fcf)'))]" mode="compound_links">

Upvotes: 1

Related Questions