I have an XML structure like the following:
<Page Depth="1">
<Page Title="Communities" Depth="2">
<Page Title="Blog" iscurrent="true" Depth="3"/>
<Page Title="Something" Depth="3"/>
<Page Title="Anything" Depth="3"/>
</Page>
<Page Title="News" Depth="2">
<Page Title="Archived news" Depth="3"/>
</Page>
</Page>
I have put this into an XML Variable called sitemap
I’m struggling with XPATH that would return the parent node of the node with the @iscurrent attribute along with its children. So from the example above, I need the following subset:
<Page Title="Communities" Depth="2">
<Page Title="Blog" iscurrent="true" Depth="3"/>
<Page Title="Something" Depth="3"/>
<Page Title="Anything" Depth="3"/>
</Page>
I have tried applying this template, but nothing gets output:
<xsl:apply-templates mode="Tabs"
select="$sitemap/Page[@iscurrent='true']/parent/*" />
The template shouldn’t be relevant, but anyhow, here is a basic version of it:
<xsl:template mode="Tab" match="*">
<li>
<xsl:if test="@iscurrent = 'true'">
<xsl:attribute name="class">current</xsl:attribute>
</xsl:when>
<xsl:value-of select="@MenuTitle" />
</li>
</xsl:template>
You want something that selects the
Pageelement having a childPagewhoseiscurrentattribute equalstrue:Demonstration:
On this input:
Output: