<list>
<field ows_ID="1081" Program="106;#Virginia" ProgramCategory="United States"/>
<field ows_ID="1082" Program="110;#NewYork" ProgramCategory="United States" />
<field ows_ID="1083" Program="106;#Texas;#112;#Virginia;#118;#Mass" ProgramCategory="United States" />
<field ows_ID="1084" Program="111;#Florida;#180;#Texas" ProgramCategory="United States" />
<field ows_ID="1085" Program="" ProgramCategory="Australia" />
<field ows_ID="1086" Program="122;#Sydney;#Melbourne" ProgramCategory="Australia" />
<field ows_ID="1087" Program="121;#Melbourne" ProgramCategory="Australia" />
<field ows_ID="1088" Program="118;#Mass" ProgramCategory="United States" />
<field ows_ID="1088" Program="123;#Brisbane" ProgramCategory="Australia" />
</list>
I have some xml out of which I need to find count where ProgramCategory is equal to some Country and Program should not equal to some states which I am getting dynamically from some other xml. From the other xml I am getting Program associated with each ProgramCategory and then I need to filter above xml with the condition
foreach(list/field[@ProgramCategory=$Country][not(contain(@Program,$State1][not(contain(@Program,$State2][not(contain(@Program,$State3][not(contain(@Program,$State4])
The problem is that I can get n no. of states which I am getting through for loop of other xml.
So Say, if I got from another xml that states associated with United States are Virginia, Texas and Florida then the count for United States is 2 and If I say states associate with Australia are Melbourne, Sydney and Brisbane then count is 1. I am using xsl 1.0.
Good question, +1.
I think there isn't a single XPath 1.0 expression that evaluates to the wanted count.
Here is an XSLT 1.0 solution:
When this transformation is applied on the provided XML document:
the wanted, correct result is produced:
II. XPath 2.0 solution:
The following single XPath 2.0 expression:
when evaluated on the same XML document (above), produces the wanted, correct result: