As I have mentioned in this post:
dynamic multiple filters in xsl
Basically, I want to apply multiple filters to my xml using “for loop” and these filters are dynamic which are coming from some other xml
sth like this:
foreach(list/field[@ProgramCategory=$Country][not(contain(@Program,$State1][not(contain(@Program,$State2][not(contain(@Program,$State3][not(contain(@Program,$Staten])
The problem is that I can get n no. of states which I am getting through for loop of other xml.
I cannot use document() function as suggested by Dimitre so I was thinking of achieving it by:
<xsl:variable name="allprograms">
<xsl:for-each select="/list2/field2">
<xsl:text disable-output-escaping="yes">[not(contains(@Program,'</xsl:text><xsl:value-of select="@ProgramID"></xsl:value-of><xsl:text disable-output-escaping="yes">'))]</xsl:text>
</xsl:for-each>
</xsl:variable>
gives me something like this:
[not(contains(@Program,'Virginia'))][not(contains(@Program,'Texas'))][not(contains(@Program,'Florida'))]
I want to use this above value as a filter in the for loop below and I am not sure how to achieve that
<xsl:for-each="list/field[not(contains(@Program,'Virginia'))][not(contains(@Program,'Texas'))][not(contains(@Program,'Florida'))]">
Before this I also have a for loop to filter United States
xsl:for-each="list/field $allprograms">
<xsl:value-of select="@ows_ID" />
</xsl:for-each>
I want my answer to be 1082, 1088..
I can add the xml here too if there is any confusion..
Jack,
From the previous solution you just need to add to this:
the following (changing the current variable definition that relies on the
document()function):Where the
"ext:"prefix needs to be bound to this namespace (this is the EXSLT namespace — if your XSLT processor doesn’t implementexslt:node-set()then you need to find whatxxx:node-set()extension it implements, or tell us what is your XSLT processor and people will provide this information):So, your
<xsl:stylesheet>may look like the following:I still recommend that the
$pFilteredStatesparameter should be passed by the initiator of the transformation — in which case you can delete the definition of$vFilteredand replace every reference to it with $pFilteredStates` and the transformation should work OK.