问题描述
我有一个巨大的
我的问题是,如何明确告诉我的 XSLT 处理器在结果输出中放置命名空间声明的位置?我在网上浏览了几个教程,但我不太明白如何解决这个问题.
部分 XSLT 代码段
......<xsl:模板匹配=章节"><bd:章节><xsl:apply-templates select="name"/><xsl:apply-templates select="page"/></bd:chapter></xsl:模板><xsl:template match="name"><bd:name><xsl:value-of select="."/></bd:name></xsl:模板>......期望输出
更新 #1
.........</书籍>
更新 #2
@polishchuk Update2 给出以下结果
我希望命名空间出现的唯一速度是在 book 节点内.请看下面
解决方案 假设您有以下
<书><name>A</name><描述>A1</描述><书><name>B</name><描述>B1</描述></root>
所需的
适当的 XSLT:
<xsl:stylesheet version="1.0" <xsl:apply-templates/></root></xsl:模板><xsl:template match="book"><bd:书><xsl:apply-templates/></bd:Book></xsl:模板><xsl:template match="name"><bd:名称><xsl:value-of select="."/></bd:姓名></xsl:模板><xsl:template match="描述"><pd:描述><xsl:value-of select="."/></pd:描述></xsl:模板></xsl:stylesheet>
您只需在 XSLT 中添加命名空间,然后使用命名空间的前缀创建节点.
更新 1:
<xsl:stylesheet version="1.0" <xsl:apply-templates/></root></xsl:模板><xsl:template match="book"><bd:Book
更新 2:
<xsl:stylesheet version="1.0" <xsl:apply-templates/></root></xsl:模板><xsl:template match="book"><Book </xsl:模板><xsl:template match="name"><名称
更新 3:这个 XSLT:
输出
<pd:Book
I have a huge
My question is, how can I explicitly tell my XSLT processor where to put namespace declaration in resulting output? I have gone through a couple of tutorials online, but I can't quite figure out how to sort this out.
Partial XSLT Snippet
...
...
<xsl:template match="chapter">
<bd:chapter>
<xsl:apply-templates select="name" />
<xsl:apply-templates select="page" />
</bd:chapter>
</xsl:template>
<xsl:template match="name">
<bd:name>
<xsl:value-of select="." />
</bd:name>
</xsl:template>
...
...
Desired Output
<?
Update #1
<?
Update #2
@polishchuk Update2 give the following result
<?
The only pace I would like the namespaces to appear is within the book node. Please see below
<?
解决方案
Suppose you have following
<root>
<book>
<name>A</name>
<description>A1</description>
</book>
<book>
<name>B</name>
<description>B1</description>
</book>
</root>
Desired
<root
Appropriate XSLT:
<xsl:stylesheet version="1.0"
You simply add namespaces in XSLT, then create nodes using namespace's prefix.
Update 1:
<xsl:stylesheet version="1.0"
Update 2:
<xsl:stylesheet version="1.0"
Update 3:This XSLT:
<xsl:stylesheet version="1.0"
Output
<root>
<pd:Book
这篇关于命名空间错误:未定义关键字上的命名空间前缀 bd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!