删除XSLT输出上的伪命名空间声明 [英] removing spurious namespace declarations on XSLT output

查看:44
本文介绍了删除XSLT输出上的伪命名空间声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个生成XML输出的XSLT。


输出树中的许多节点都包含名称空间声明for

源文档中使用的命名空间,即使它们不是结果文档或样式表中使用的



我发现(对于样式表中引用的名称空间)甚至

如果我在结果的根元素上放置一个显式的名称空间声明

树,名称空间声明是在结果的各个节点上重复

树但使用不同的前缀


我想要的是对于结果树中使用的命名空间,它们被声明为<根元素上的
,其他名称空间根本不应该输出。为什么

这么难以实现,或者我错过了一些大的东西?


TIA


Andy < br>



I have an XSLT which is producing XML output.

many of the nodes in the output tree contain namespace declarations for
namespaces that are used in the source document even though they are not
used in the result document or the stylesheet

also I find that (for namespaces that are referenced in the stylesheet) even
if I put an explicit namespace declaration on the root element of the result
tree, namespaces declarations are repeated on individual nodes of the result
tree but with a different prefix

all I want is that for namespaces used in the result tree, they are declared
on the root element, and other namespaces shouldn''t be output at all. why is
this so difficult to achieve or am I missing something big here?

TIA

Andy

推荐答案

典型 - 在我的头发上钻了几个小时之后,我在发布问题后取得了一些进展

br />

看来虚假的名称空间声明是由于我使用

< xsl:copywhich从源节点复制所有名称空间声明,

无论是否使用


所以我的新问题是,如何复制< xsl:copy>

的行为而不复制所有命名空间声明?


Andy

Andy Fish < aj **** @ blueyonder.co.ukwrote in message

新闻:1k ***************** @ text.news.blueyonder。 co.u k ...
typical - after tearing my hair out on it for hours, I made some progress
just after posting the question

it appears the spurious namespace declarations are due to me using
<xsl:copywhich copies all namespace declarations from the source node,
regardless of whether they are used

so my new question is, how can I replicate the behaviour of <xsl:copy>
without copying all the namespace declarations?

Andy
"Andy Fish" <aj****@blueyonder.co.ukwrote in message
news:1k*****************@text.news.blueyonder.co.u k...

hi,


我有一个产生XML输出的XSLT。


输出树中的许多节点包含源文档中使用的

名称空间的名称空间声明,即使它们不是
在结果文档或样式表中使用


我也发现(对于样式表中引用的名称空间)

即使我放了一个显式的名称空间声明在

结果树的根元素上,命名空间声明在结果树的各个节点上重复,但是具有不同的前缀


我想要的是对于结果树中使用的命名空间,它们是在根元素上声明的
,而其他命名空间不应该在

输出所有。为什么这么难以实现,或者我错过了一些大的东西

这里?


TIA


Andy



I have an XSLT which is producing XML output.

many of the nodes in the output tree contain namespace declarations for
namespaces that are used in the source document even though they are not
used in the result document or the stylesheet

also I find that (for namespaces that are referenced in the stylesheet)
even if I put an explicit namespace declaration on the root element of the
result tree, namespaces declarations are repeated on individual nodes of
the result tree but with a different prefix

all I want is that for namespaces used in the result tree, they are
declared on the root element, and other namespaces shouldn''t be output at
all. why is this so difficult to achieve or am I missing something big
here?

TIA

Andy



在文章< nt **************** @ text中。 news.blueyonder.co.uk>,

Andy Fish< aj **** @ blueyonder.co.ukwrote:
In article <nt****************@text.news.blueyonder.co.uk>,
Andy Fish <aj****@blueyonder.co.ukwrote:

> ;看起来虚假的命名空间声明是由于我使用
< xsl:copywhich从源节点复制所有命名空间声明,
无论是否使用

所以我的新问题是,如何在不复制所有命名空间声明的情况下复制< xsl:copy>
的行为?
>it appears the spurious namespace declarations are due to me using
<xsl:copywhich copies all namespace declarations from the source node,
regardless of whether they are used

so my new question is, how can I replicate the behaviour of <xsl:copy>
without copying all the namespace declarations?



您可以通过创建新元素来复制元素:


< xsl:element name =" local-name( )" namespace =" namespace-uri()">

< xsl:copy-of select =" @ *" />

...

< / xsl:element>


- Richard

-

"应考虑在一些字母表中需要多达32个字符

" - X3.4,1963。

You could copy elements by creating new elements:

<xsl:element name="local-name()" namespace="namespace-uri()">
<xsl:copy-of select="@*"/>
...
</xsl:element>

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.


Andy Fish写道:
Andy Fish wrote:

我有一个生成XML的XSLT输出。


输出树中的许多节点包含源文档中使用的

名称空间的名称空间声明,即使它们不是

在结果文档或样式表中使用
I have an XSLT which is producing XML output.

many of the nodes in the output tree contain namespace declarations for
namespaces that are used in the source document even though they are not
used in the result document or the stylesheet



您是否在xsl:stylesheet元素上使用exclude-result-prefixes

< http://www.w3.org/TR/xslt#stylesheet-element>

那样你应该摆脱名称空间的名称空间声明

结果文件中没有使用。


-


Martin Honnen
http://JavaScript.FAQTs.com/


这篇关于删除XSLT输出上的伪命名空间声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆