DOMParser或XMLSerializer都会在IE9中删除我的名称空间声明 [英] Either DOMParser or XMLSerializer is dropping my namespace declaration in IE9

查看:124
本文介绍了DOMParser或XMLSerializer都会在IE9中删除我的名称空间声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我认为可能有比我正在做的事情更清洁的解决方案,但是我想知道这是否是已知问题,是否有明显的问题我做错了,等等...

So I think there are probably cleaner solutions than what I am doing anyway, but I'm wondering if this is a known issue, if there's something obvious I'm doing wrong, etc...

出于不值得描述的原因,我有一些Javascript代码,在一个可能的路径中,它是使用DOMParser从字符串中加载XML,然后使用XMLSerializer将其序列化回字符串. XML文档是XSL样式表.主要的xsl:stylesheet标记中有两个xmlns元素:一个声明一个xsl命名空间,另一个声明一个我使用的自定义命名空间. (称之为"foo")

For reasons not worth describing, I have some Javascript code that, in one possible path, is loading XML from a string using DOMParser, then serializing it back to a string with XMLSerializer. The XML document is an XSL stylesheet. There are two xmlns elements in the main xsl:stylesheet tag: One which declares the xsl namespace, and another which declares a custom namespace that I use. (Call it "foo")

至少在IE9中,当我通过DOMParser从往返返回输出时,xmlns:xsl元素仍然存在,但是xmlns:foo元素丢失了.这是预期的行为吗?我想念什么?

In IE9, at least, when I get the output back from the round trip through DOMParser, the xmlns:xsl element is still there, but the xmlns:foo element is missing. Is this expected behavior? What am I missing?

推荐答案

我制作了一个测试用例 http://home.arcor.de/martin.honnen/javascript/2012/test2012070901.html ,我可以确认Windows 7上IE 9的输出是

I made a test case http://home.arcor.de/martin.honnen/javascript/2012/test2012070901.html and I can confirm that the output with IE 9 on Windows 7 is

Input
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:foo="http://example.com/foo">
<xsl:template match="foo:bar">Test</xsl:template>
</xsl:stylesheet>
Output
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="foo:bar">Test</xsl:template>
</xsl:stylesheet>

因此删除了名称空间声明.我认为IE 9中存在一个错误,您可能需要检查connect.microsoft.com是否已报告过类似的内容,如果没有,请进行归档.有人在使用IE 10阅读吗? IE 10显示什么?

so the namespace declaration is dropped. I consider that a bug in IE 9, you might want to check connect.microsoft.com whether anything like that is already reported, and if not file it. Is anyone reading here using IE 10? What does IE 10 show?

[edit] IE 10上存在连接问题,可能与以下问题有关: https://connect.microsoft.com/IE/feedback/details/728093/xmlserializer-omits-xmlns-attribute .

[edit]There is a connect issue on IE 10, probably related: https://connect.microsoft.com/IE/feedback/details/728093/xmlserializer-omits-xmlns-attributes.

这篇关于DOMParser或XMLSerializer都会在IE9中删除我的名称空间声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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