我正在创建phpdoc2的模板,并尝试找出如何防止在从我的模板创建文档时将属性
请按照要求翻译以下其中一个.xsl文件的内容,这是api-doc.xsl:
这是api-doc/file.xsl的一部分代码:
元素
xmlns="http://www.w3.org/1999/xhtml"
添加到生成的HTML的根级元素中。我的模板中的.xsl文件会生成包含HTML片段的文件,这就是为什么<html>
标签不是根级元素的原因。看起来phpdoc2使用XSLT v1.0,所以我的选项有点受限。经过一些搜索,最常见的答案是在每个.xsl文件的<xsl:stylesheet>
标记上使用exclude-result-prefixes
属性,并将其值设置为#all
或#default
,因为您不能直接使用xmlns
作为要排除的命名空间。但我尝试了这个方法,在我的模板中的每个.xsl文件上设置了exclude-result-prefixes
,但它没有起作用。请按照要求翻译以下其中一个.xsl文件的内容,这是api-doc.xsl:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="#all">
<xsl:output indent="no" method="html"/>
<xsl:include href="chrome.xsl"/>
<xsl:include href="api-doc/property.xsl"/>
<xsl:include href="api-doc/class.xsl"/>
<xsl:include href="api-doc/constant.xsl"/>
<xsl:include href="api-doc/function.xsl"/>
<xsl:include href="api-doc/docblock.xsl"/>
<xsl:include href="api-doc/file.xsl"/>
<xsl:template name="content">
<xsl:apply-templates select="/project/file[@path=$path]"/>
</xsl:template>
</xsl:stylesheet>
这是api-doc/file.xsl的一部分代码:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="#all">
<xsl:output indent="no" method="html"/>
<xsl:template match="file">
<div class="text-content">
<!-- ... -->
</div>
</xsl:template>
</xsl:stylesheet>
元素
<div class="text-content"></div>
加入了属性 xmlns="http://www.w3.org/1999/xhtml"
。
xsl:output
是什么样子的?你能展示一下你的 XSL 吗? - JLRisheapi-doc
XSLT 的样子吗?是你自己创建的还是别人创建的?如果你的结果中有xmlns="http://www.w3.org/1999/xhtml"
,那么无论如何都无法通过排除命名空间前缀来移除它,因为结果实际上正在使用该命名空间。 - JLRishe