我开始使用XSLT,我不明白这行:file:file在这个XSLT中代表什么?
<xsl:apply-templates select="file:file/file:description" />
为什么有3个file
S' 我知道我的XML文件中的一个标签名为“file”,但为什么在前缀“file:”?
下面是实际的代码:
<?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"
xmlns:file="http://phpdox.de/xml#"
exclude-result-prefixes="#default file"
>
<xsl:output method="html" indent="yes" encoding="utf-8" />
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="file:file/file:description" />
</body>
</html>
<xsl:template match="file:description">
<header>
<p><xsl:value-of select="@compact" /></p>
<p><xsl:value-of select="file:description" /></p>
</header>
</xsl:template>
</xsl:stylesheet>
和源XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<file xmlns="http://phpdox.de/xml#">
<class>
<docblock>
<description compact="foo bar"/>
[...]
我怀疑源文件是否看起来像这样,因为它的内容与给定的命名空间'http:// phpdox.de/xml#'不匹配。 – Lucero 2011-04-03 22:47:51
是的,你是对的,我已经清理了太多...我会编辑 – FMaz008 2011-04-03 23:10:32