xml file bad instructions do not allow matching

Keywords: xml Apache Hadoop encoding

xml file bad instructions do not allow matching

Problem description

The xml file in Eclipse reported the following error:

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

The error file is empty-configuration.xml in hadoop-common project in Hadoop 2.7.1 source code. The directory of this file in the project is as follows:

The contents of the document are as follows:

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

Problem analysis

I searched for this error message on the Internet. It's true. The content is as follows:

xml files can not be parsed. Generally, the problem lies in the xml format, and the problem often occurs in the header of xml files.
Reason:
(1) Generally, it is caused by spaces or carriage returns in the header of xml files.
(2) Letter case problem.
For example: < XML version = "1.0" encoding = "UTF-8"? > cannot be written as < XML version = "1.0" encoding = "UTF-8"? >
Conclusion:
There should be no other characters in front of <? XML version = "1.0" encoding = "UTF-8"? > such as spaces, carriage returns, line feeds, or the above exceptions will occur.

Solution

I moved <? XML version = "1.0"? > to the first line, and solved the error. When I went to check the file that hadoop just unzipped, I found that there was indeed this file, which was not caused by Maven download, so I was very puzzled, isn't Apache such a big problem?

The revised contents are as follows:

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

So far, I'm still confused. If you know, you can leave a message to let me know. Thank you!

Posted by Rayman3.tk on Fri, 03 Jan 2020 21:27:30 -0800