1
問題:在我之前的問題Table of contents XSL中繼續使用@potame提供的解決方案時,我想知道是否有某種方法不將CSS樣式應用於某些列表項。提供的CSS是如下:將CSS應用於某些列表項
<style>
body {
text-align: justify;
}
ol, ul {
counter-reset: item;
}
li {
display: list-item;
list-style-type: none;
}
li.chapter::before {
content: "";
}
li:before {
content: counters(item, ".") ". ";
counter-increment: item
}
</style>
繼內容也@potame在前面的問題提供該表的推理,我所做的XSL模板處理的章,節,小節和subsubsections:
<xsl:template match="t:chapter">
<li class="chapter">
<h2>
<a name="{@id}"><xsl:value-of select="t:title"/></a>
</h2>
<br/>
<ol>
<xsl:apply-templates select="*[not(self::t:title)]"/>
</ol>
</li>
</xsl:template>
<xsl:template match="t:section">
<li>
<a name="{@id}"><xsl:value-of select="t:title"/></a>
<br/>
<ol>
<xsl:apply-templates select="*[not(self::t:title)]"/>
</ol>
</li>
</xsl:template>
<xsl:template match="t:subsection">
<li>
<a name="{@id}"><xsl:value-of select="t:title"/></a>
<br/>
<ol>
<xsl:apply-templates select="*[not(self::t:title)]"/>
</ol>
</li>
</xsl:template>
<xsl:template match="t:subsubsection">
<li>
<a name="{@id}"><xsl:value-of select="t:title"/></a>
<xsl:apply-templates select="*[not(self::t:title)]"/>
</li>
</xsl:template>
而下面是處理列表和段落模板,可以出現在內容:
<xsl:template match="list:ol">
<ol>
<xsl:apply-templates/>
</ol>
</xsl:template>
<xsl:template match="list:ul">
<ul>
<xsl:apply-templates/>
</ul>
</xsl:template>
<xsl:template match="list:li/p:p">
<li>
<xsl:apply-templates/>
</li>
</xsl:template>
<xsl:template match="p:p">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
的問題是,當我在內容列表中的項目,HTML結果顯示如下:
Chapter 1
1.1. Motivation
...some text...
Example list:
1.1.0.1. text
1.1.0.2. tex
1.1.0.3. text
1.1.0.4. text
而在HTML期望的結果是這樣的:
Chapter 1
1.1. Motivation
...some text...
Example list:
1. text
2. text
3. text
4. text
這基本上意味着我想要的「正常有序列表」,而不是看起來像是一個sububsubsection什麼的...
有什麼建議嗎?
使用計數器復位:項目;在你想要的列表上,然後再次開始計數 - counter-increment:item –
好的,但是我在哪裏寫的?裏面的