xml文件错误之指令不允许匹配

xml文件错误之指令不允许匹配

问题描述

Eclipse中xml文件报出如下错误:

The processing instruction target matching "[xX][mM][lL]" is not allowed.

报错的文件是hadoop2.7.1源码中hadoop-common项目中的empty-configuration.xml,此文件存在项目中的目录如下:

文件内容如下:

<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<?xml version="1.0"?>
<configuration>
</configuration>

问题解析

在网上搜了一下这个错误信息,还真有,内容如下:

xml文件不能被解析,一般出现这样的问题在于xml格式上,并且问题多出现在xml文件的头部。
原因:
(1)一般多是因为xml文件头部有了空格或回车导致的。
(2)字母大小写问题。
例如:<?xml version="1.0" encoding="UTF-8"?>不能写成<?XML version="1.0" encoding="UTF-8"?>
结论:
<?xml version="1.0" encoding="UTF-8"?>前面不要有任何其他字符,如空格、回车、换行这些否则就会出现上面的异常。

解决方法

本人就将<?xml version="1.0"?>挪到了第一行的位置,错误解决,当本人在去查看hadoop刚解压的文件时,发现确实有这个文件,不是Maven下载导致的,所以本人就很纳闷,Apache不至于出这么大的问题吧?

修改过的内容如下:

<?xml version="1.0"?>
<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<configuration>
</configuration>

至今仍是疑惑,有知道的朋友可以留言告知,谢谢!

转载于:https://my.oschina.net/u/3754001/blog/1939106

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值