Home > front end >  Filtering XSLT Template By List of IDs
Filtering XSLT Template By List of IDs

Time:08-02

Im picking up a legacy xslt file that needs to be updated and ive never coded in xsl before. I've tried a number of ways to achieve this, but can't get correct results. I have an xslt that generates a csv file. Before the csv file is saved, im trying to filter out the Allocations template if an ID != 3 or 7.

I've tried this and every possible iteration: <xsl:apply-templates select="Allocations/Allocation[ID != 3 and 7]" mode="FieldMap"/>

This is what I currently have:

<xsl:param name="filterType" select="'3,7'"/>
<xsl:variable name="filter" select="concat(',', $filterType, ',')"/>
<xsl:template match="/Trade">

<xsl:variable name="Allocations">
 <xsl:apply-templates select="Allocations[contains($filter, concat(',', Allocations/Allocation/ID, ','))]" mode="FieldMap"/>
</xsl:variable>```


Any guidance would be greatly appreciated

CodePudding user response:

XSLT 1.0

select="Allocations/Allocation[ID != '3' and ID != '7']" mode="FieldMap"/>

XSLT 2.0 and later

select="Allocations/Allocation[not(ID=('3','7'))]" mode="FieldMap"/>
  • Related