0

私は以下のような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.â€&lt;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>
4

1 に答える 1

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要素のテンプレートなど) のいずれかによって処理されます。

于 2012-12-14T10:19:47.393 に答える