Xml XSL-多模板冲突?
我目前正在为一些查找工具编写XSL样式表,但我相信样式表中的多个模板之间存在冲突。诚然,我对XSL相当陌生,所以我可能在这里遗漏了一些东西。我希望我已经包括了所有必要的细节 以下是我希望模板执行的代码:Xml XSL-多模板冲突?,xml,xslt,Xml,Xslt,我目前正在为一些查找工具编写XSL样式表,但我相信样式表中的多个模板之间存在冲突。诚然,我对XSL相当陌生,所以我可能在这里遗漏了一些东西。我希望我已经包括了所有必要的细节 以下是我希望模板执行的代码: <c05 level="item"><did><unittitle><title render="italic">Souvenir</title>, undated</unittitle></did> <s
<c05 level="item"><did><unittitle><title render="italic">Souvenir</title>, undated</unittitle></did>
<scopecontent>
<p>With sketches of Confederate Generals and Confederate flags and a <emph render="doublequote">bird's eye view</emph> of Charleston.</p>
</scopecontent>
</c05>
现在,这两个模板分别设置了我的容器列表布局和一些文本格式。布局的模板如下所示:
<xsl:template name="item">
<xsl:variable name="title">
<xsl:if test="did/unitid">
<xsl:value-of select="did/unitid"/><xsl:text>. </xsl:text>
</xsl:if>
<xsl:value-of select="did/unittitle"/>
<xsl:if test="did/unitdate">
<xsl:text>, </xsl:text><xsl:value-of select="did/unitdate"/>
</xsl:if>
</xsl:variable>
<div style="margin-left:80px; padding-top:10px;"><xsl:value-of select="$title" /></div>
<div class="c01sc" style="margin-left:80px;"><xsl:value-of select="scopecontent" /></div>
<xsl:element name="a">
<xsl:call-template name="addidtoc"/>
</xsl:element>
</xsl:template>
下面是文本格式的代码。它调用另一个执行某些格式设置的模板:
<xsl:template match='emph'>
<xsl:call-template name='render'/>
</xsl:template>
<xsl:template name='render'>
<xsl:choose>
<xsl:when test="@render='italic'">
<xsl:element name="i">
<xsl:call-template name="addid"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:when>
etc.....
</xsl:template>
问题是,只执行第一个布局模板的操作。虽然生成了我的布局样式,但是由于emph标记,应该用双引号括起来的区域仍然是普通的。这是模板层次结构的问题,还是我完全做错了什么?希望这有点道理。如果能得到任何帮助,我将不胜感激 只有在使用xsl:call-template显式调用命名模板时,才会调用该模板。只有在xsl:apply templates指令中选择与之匹配的节点时,才会调用具有匹配属性的模板规则1。这应该可以解释为什么你的模板没有执行。你能发布你获得的输出和你想要的输出吗?可能有用的还有第二个模板的完整代码。我明白你的意思。我在代码中移动了一些内容,因此现在在找到相应的匹配项后,将调用布局的项模板和格式化的渲染模板。但是,即使如此,也只调用项布局模板。项目模板带来的样式可能会覆盖格式呈现吗?