我有两个模板 - List.xsl 和 Main.xsl。Main.xsl 通过 xsl:include 包含在 List.xsl 中。当使用 xsltproc 转换 List.xsl 时,它生成的所有代码都没有任何缩进,但如果将相同的代码放在 Main.xsl 中而不是<xsl:apply-templates />
在正文标记之间,则缩进起作用。在这两种情况下,缩进也适用于撒克逊人。是 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>
主文件
<?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>
第二种情况下的输出示例:
<!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>