Reputation: 718
I'm trying to write some XSLT which basically should go through the following algorithm:
if child of current node is of type Accordion
if child of Accordion node is of type AccordionItem
take the AccordionItem's title and content and display in <div> tags
end if
end if
It seems pretty straight forward, but the code I currently have doesn't appear to be working as it should. I must be missing something, but I can't figure out exactly what. Here's my XSLT code so far:
<xsl:for-each select="$currentPage/ancestor-or-self::Home//AccordionItem[@isDoc]">
<div id="accordion">
<h3><a href='#'><xsl:value-of select="accordionItemTitle"/></a></h3>
<div><xsl:value-of select="accordionItemContent" disable-output-escaping="yes" />
</div>
</div>
</xsl:for-each>
Can anyone offer any suggestions as to why this wouldn't be working correctly? Thanks in advanced!
Upvotes: 1
Views: 1312
Reputation: 6304
It seems that your XPath isn't quite behaving as you've defined in your algorithm and is navigating to the node of type Home
, is that intended?
If not, try modifying the XPath to the following:
<xsl:for-each select="$currentPage/Accordion/AccordionItem[@isDoc]">
Upvotes: 2