Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xsl:attributes strips the "content"

Tags:

plone

diazo

I'm writing some rules in Diazo. I want, in case the user browses the "viewer" section (a browser view, not a real plone folder), to drop the "selected" class for the "home" tab in the globalnav and put "selected" class for the "viewer" tab.

<replace css:content="#portal-globalnav" css:theme="#portal-globalnav" />
<drop if-path="viewer/" 
        css:content="#portaltab-index_html"
        attributes="class" />    
<xsl:template if-path="viewer/"
          match="//li[@id='portaltab-viewer']/">
<xsl:attribute name="class">selected</xsl:attribute>
</xsl:template>

But the result it's a right li portaltab-viewer with the "selected" class, but without any content inside! I obtain an empty "li" tag in the portal-globalnav O.O

What's wrong? Vito

like image 709
Vito Avatar asked Jan 26 '26 14:01

Vito


1 Answers

You need to recurse into the content of the element with xsl:apply-templates. Try:

<replace if-path="/viewer" css:content-children="li#portaltab-viewer"><xsl:attribute name="class">selected</xsl:attribute><xsl:apply-templates select="node()"/></replace>

The lack of whitespace before the xsl:attribute is necessary as I don't think I ever got around to making Diazo ignore whitespace around xsl:* elements.

like image 91
Laurence Rowe Avatar answered Jan 29 '26 13:01

Laurence Rowe