如何修复XML中缺少的名称空间前缀 [英] How to fix missing namespace prefix in XML

查看:160
本文介绍了如何修复XML中缺少的名称空间前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XML文件,我自己无法修改.它包含以下根元素:

I have an XML file which I can't modify by myself. It contains the following root element:

<foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" noNamespaceSchemaLocation="some.xsd">

如您所见,noNamespaceSchemaLocation缺少前缀xsi:.这导致XmlReader在验证时找不到架构信息.如果我添加前缀,那么一切都很好.但是正如我所说,我不能修改XML文件(除了测试).我是从外部来源获得的,我的工具应该会自动对其进行验证.

As you can see the prefix xsi: is missing for noNamespaceSchemaLocation. This causes the XmlReader to not find the schema information while validating. If I add the prefix all is good. But as I said I can't modify the XML file (besides testing). I get them from an external source and my tool should automatically validate them.

是否可以在没有xsi:前缀的情况下使XmlReader解释noNamespaceSchemaLocation?我不希望在预处理步骤或类似的操作中在XML内添加前缀,因为源应完全保持原样.

Is there a possibility to make the XmlReader interpret noNamespaceSchemaLocation without the xsi: prefix? I don't want to add the prefix inside the XML in a preprocessing step or something like that as the sources should exactly remain as they are.

推荐答案

XML错误,需要对其进行修复.要么让您的供应商提高其发送的质量,要么在到达时对其进行维修.

The XML is wrong and you need to fix it. Either get your supplier to improve the quality of what they send, or repair it on arrival.

我不知道您为什么要保留损坏的源(所有质量标准都说这是不好的做法),但是保留损坏的原始版本和修复版本当然是可能的.

I don't know why you want to retain the broken source (all quality standards say that's bad practice), but it's certainly possible to keep the broken original as well as the repaired version.

这篇关于如何修复XML中缺少的名称空间前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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