2

List.xsl と Main.xsl という 2 つのテンプレートがあります。Main.xsl は xsl:include で List.xsl に含まれます。List.xsl を xsltproc で変換すると、生成されるすべてのコードにインデントがありませんが、<xsl:apply-templates />body タグの間ではなく Main.xsl に同じコードを配置すると、インデントが機能します。また、どちらの場合も、インデントはサクソン語で問題なく動作します。xsltprocのバグですか?

リスト.xsl

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:xdt="http://www.w3.org/2005/04/xpath-datatypes"
  xmlns="http://www.w3.org/1999/xhtml">
  <xsl:include href="Main.xsl" />

  ...

</xsl:stylesheet>

メイン.xsl

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/1999/xhtml">
  <xsl:output
    omit-xml-declaration="yes"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    method="xml"
    encoding="utf-8"
    indent="yes"
    cdata-section-elements="script style" />
  <xsl:strip-space elements="*" />

  <xsl:template match="/">
    <html>
      <head>
        <title> List </title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      </head>
      <body>
        <xsl:apply-templates />
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

最初のケースの出力例:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title> List </title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  </head>
  <body><dl class="list"><dt>Term</dt><dd><ul><li> ... </li></ul></dd></dl></body>
</html>

2 番目のケースの出力例:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title> List </title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  </head>
  <body>
    <dl class="list">
      <dt>Term</dt>
      <dd>
        <ul>
          <li> ... </li>
        </ul>
      </dd>
    </dl>
  </body>
</html>
4

1 に答える 1

1

List.xsl にxsl:output要素がある場合、その値はインポートされたスタイルシートで指定された値よりも優先されます。List.xsl で指定されていない出力プロパティについては、インポートされた Main.xsl で指定された値が適用されます。xsl:outputList.xsl に を含む要素がない場合indent="yes"、はい、これは libxslt のバグのようです。

于 2012-09-09T18:06:33.687 に答える