Thursday, 21 August 2014

XSLT check if one of sibling elements contain certain parameter



I have XML which lists my menu items. Problem is, it lists all items regardless of their language and I need to filter out all items that don't belong to current language which is stored in $language variable.


This is my XSLT which is supposed to filter out menu items that don't belong to current language (it's also supposed to filter hidden items):


<xsl:apply-templates select="page[not(types/type = 'hidden' or types/type != $language)]"/>


Currently, only about element get's through and that is probably because my Home item also has index besides en.


So, how can I filter out element if it doesn't contain correct type with current language in it, while ignoring other properties?


This is my XML:



<navigation>
<page handle="en" id="1">
<name>Home</name>
<types>
<type>en</type>
<type>index</type>
</types>
</page>
<page handle="he" id="2">
<name>Home HE</name>
<types>
<type>he</type>
</types>
</page>
<page handle="about" id="3">
<name>About</name>
<types>
<type>en</type>
</types>
</page>
</navigation>

No comments:

Post a Comment