Let this be the xml:
... some other parent elements here ...
<subject group="a">Economy</subject>
<subject group="b">Math</subject>
<subject group="a">Finance</subject>
<subject group="c">Arts</subject>
... some other elements here
I would like to process and print a heading where group ‘a’ and ‘b’ is under one heading, and c is in another heading. ‘C’ is not a definite string, it can be ‘d’, ‘d’. I just want to seperate ‘a’ and ‘b’, from anything else. So an example output would be
Main Subjects (a and b)
- Economy Finance Math
Others
- Arts
Now, I have this code for the “Others” part:
<xsl:if test="not(subject/@group[. = 'a'] or subject/@group[. = 'b])">
<h2>Others</h2>
<ul>
<xsl:for-each select="subject">
<xsl:sort select="./@group"/>
<xsl:if test="@group!='a'and @type!='b'">
<xsl:apply-templates select="."/>
</xsl:if>
</xsl:for-each>
</ul>
</xsl:if>
This doesn’t work properly. I’ve tried without the not() and with !=
In short i just want to know if there is any element besides those of group a and b. If there is, print something, if there isn’t anything, don’t print out the heading “Others”.
Any help will be appreciated.
EDIT:
@group/.='a'or@group ='a'both are fine,