【发布时间】:2010-10-16 08:51:27
【问题描述】:
这是一篇简单但有效的 Docbook 文章:
<?xml version="1.0" encoding="utf-8"?>
<article xmlns="http://docbook.org/ns/docbook" version="5.0">
<title>I Am Title</title>
<para>I am content.</para>
</article>
这是一个样式表,如果我删除上面的 xmlns 属性,则选择 title,如果我把它留在里面,则不会:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:apply-templates select="article"/>
</xsl:template>
<xsl:template match="article">
<p><xsl:value-of select="title"/></p>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>
如果 XPath 具有命名空间属性,我如何让 XPath 选择 title 到 article?
【问题讨论】:
标签: xslt xpath namespaces