xml文件錯誤之指令不容許匹配

xml文件錯誤之指令不容許匹配

問題描述

Eclipse中xml文件報出以下錯誤:express

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

報錯的文件是hadoop2.7.1源碼中hadoop-common項目中的empty-configuration.xml,此文件存在項目中的目錄以下:apache

文件內容以下:app

<!--
   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>

問題解析

在網上搜了一下這個錯誤信息,還真有,內容以下:less

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"?>前面不要有任何其餘字符,如空格、回車、換行這些不然就會出現上面的異常。oop

解決方法

本人就將<?xml version="1.0"?>挪到了第一行的位置,錯誤解決,當本人在去查看hadoop剛解壓的文件時,發現確實有這個文件,不是Maven下載致使的,因此本人就很納悶,Apache不至於出這麼大的問題吧?ui

修改過的內容以下:this

<?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>

至今還是疑惑,有知道的朋友能夠留言告知,謝謝!spa

相關文章
相關標籤/搜索