我有一个XML文件,如下所示:
<NOP>A focus on individual exhibitors is essential, though, in order to
understand how these figures influenced American (and global) culture and
how audiences were attracted to movies and movie theaters. Charles Musser
writes in his examination of Lyman Howe’s career that “a focus on
exhibition lends itself to industrial history precisely because it must
address the economic basis of the motion picture industry—the showman’s
ability to bring patrons through the front door.â€<ENREF>1</ENREF> In order
to understand the artistic and managerial influences of showmen like Samuel
Lionel Rothafel (“Roxyâ€) and Sidney Patrick Grauman, one must analyze
their construction of stardom, their ethnic heritage and cultural background,
their facility with music, theater, film, and other performing arts, and the
ways in which they motivated patrons to enter their “front door.â€
</NOP>
我正在使用下面的XSLT与XML间谍,但它不适用于'ENREF'。任何帮助
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="NOP">
<div class="no-indent"><span><xsl:value-of select="."/></span></div>
</xsl:template>
<xsl:template match="ENREF">
<small>
<sup>
<xsl:element name="a">
<xsl:attribute name="id">enref-<xsl:value-of select="."/></xsl:attribute>
<xsl:attribute name="href">#fn<xsl:value-of select="."/></xsl:attribute>
<xsl:value-of select="."/>
</xsl:element>
</sup>
</small>
</xsl:template>
</xsl:stylesheet>
答案 0 :(得分:1)
编写匹配某个元素的模板是不够的,还需要确保处理该元素。您没有向我们展示您想要的结果,所以我必须猜测您想要实现的目标,但首先尝试更改
<xsl:template match="NOP">
<div class="no-indent"><span><xsl:value-of select="."/></span></div>
</xsl:template>
到
<xsl:template match="NOP">
<div class="no-indent"><span><xsl:apply-templates/></span></div>
</xsl:template>
这样,NOP
元素的子节点就可以通过内置模板(确保<xsl:apply-templates/>
确保为孙子孙辈和其他后代保持处理)或由你的模板(如ENREF
元素的模板)。