2013-10-10 34 views
1

像這個例子https://plone-theming-with-diazo.readthedocs.org/en/latest/snippets_diazo/recipes/index.html#add-attributes-on-the-fly 我需要修改所有特定標籤的類,添加一個值(在內容側)。修改某些標籤的屬性添加值

此規則一點兒也不工作:

<xsl:template css:match="ul.navTreeLevel0 li"> 
     <xsl:attribute name="class"><xsl:value-of select="./@class"/> no-bullet</xsl:attribute> 
    </xsl:template> 

我想在任何L1標籤添加具有「navTreeLevel0」類的UL裏面的值「沒有子彈」。

重氮不會引發異常。

在同一規則文件我有一個類似的情況,但在這種情況下工作:

<replace content="//div[contains(@class,'cell')]/@class"> 
    <xsl:attribute name="class"> 
    <xsl:if test='contains(current(),"width-3:4")'>nine large-9 columns</xsl:if> 
    <xsl:if test='contains(current(),"width-2:3")'>height large-8 columns</xsl:if> 
    <xsl:if test='contains(current(),"width-1:2")'>six large-6 columns</xsl:if> 
    <xsl:if test='contains(current(),"width-1:3")'>four large-4 columns</xsl:if> 
    <xsl:if test='contains(current(),"width-1:4")'>three large-3 columns</xsl:if> 
    <xsl:if test='contains(current(),"width-full")'>twelve large-12 columns</xsl:if> 
    </xsl:attribute> 
</replace> 

出了什麼事? 維託

回答

2

這可能是同樣的理由,在這種類似的問題,我今天看了:diazo xsl:template not applying when inside secondary rules file

報價從那裏重氮文檔:「內聯XSL指令必須直接根標籤放在裏面,並無條件地應用。 「

好吧,顯然一些xsl也可以在根規則標籤之外工作,看到代碼的其他部分工作。

如果你用你的代碼中的css:match="..."替換match="obviously wrong[xsl" Diazo會引發異常嗎?如果不是,那麼可能的原因是您的xsl被忽略並需要移動到根角色標記。

+1

謝謝Maurits。修改css:匹配放置明顯錯誤的語法,如「// * asd []」Diazo引發異常(AssertionError:意外符號:'/'爲0)。 – Vito

+1

我寫的第一條規則是在主要的rules.xml文件中,而第二條規則(工作的)是位於另一個規則 Vito