Error while reading xml file

When the character encoding of the document is other than the encoding in XML declaration (Header), meaning encoding in xml file header is UTF-16 "" but the data is UTF-8, then Parser step in XML Hierarchy stage reports below Fatal error and stops processing the file.

Problem

Cause

When the character encoding of the document is other than the encoding in XML declaration (Header), meaning encoding in xml file header is UTF-16 «<?xml version=»1.0″ encoding=»utf-16″?>» but the data is UTF-8, then Parser step in XML Hierarchy stage reports below Fatal error and stops processing the file.

Fatal Error: CDIER0410E: Error in step=XML_Parser,
cause=com.ibm.e2.xml.exceptions.XMLRuntimeException: CDIER0006E: Unable
to create the XML input stream, step=XML_Parser,
cause=java.lang.NullPointerException.

Resolving The Problem

To resolve the issues, change encoding in XML declaration (Header) to correct encoding in xml source file/ files.

For example: If encoding in xml file header is UTF-16 and data in xml source file is UTF-8 encoding, then change encoding in xml source file / files header to utf-8, like below.

<?xml version=»1.0″ encoding=»utf-8″?>

[{«Product»:{«code»:»SSVSEF»,»label»:»IBM InfoSphere DataStage»},»Business Unit»:{«code»:»BU059″,»label»:»IBM Software w/o TPS»},»Component»:»—«,»Platform»:[{«code»:»PF002″,»label»:»AIX»},{«code»:»PF010″,»label»:»HP-UX»},{«code»:»PF016″,»label»:»Linux»},{«code»:»PF027″,»label»:»Solaris»},{«code»:»PF033″,»label»:»Windows»}],»Version»:»11.3;11.5;8.7;9.1″,»Edition»:»»,»Line of Business»:{«code»:»LOB10″,»label»:»Data and AI»}}]

MikeAtCalidus

Junior Member

  • Total Posts : 77
  • Reward points : 0
  • Joined: 2013/02/14 03:20:04
  • Status: offline

There is  related to this topic, but it is locked, so I’ve created a new one in case it helps anyone with a similar problem. There may well be other causes of the same problem, but this is the solution that works for me.

 There have been a number of occasions when MPLAB-X has refused to open a project, displaying the very unhelpful message of the title «Errors while reading XML from <Project Name>».  Aside from not providing any information about what the erros were or where it encountered them, after displaying this message the IDE appears to be completely unable to open the project again, even after restarting the PC.

 My development environment includes the Source Control Tool (SCT), in which I save some of the contents of the nbproject folder, but only those files that are required to build the binary file from the command line.  (Netbeans, is poor in the way it manages .mk files, but that’s a .)

 It appears that (in my case) the XML problem is caused when the configurations.xml file stored in the nbproject directory is somehow ‘out of sync’ with the one stored in the nbprojectprivate directory.  This can happen if you use the SCT to change the version while the project is open in MPLAB-X.  This may well be considered as being an unsafe practice, to be avoided at all costs, but it can occur unintentionally.  The IDE detects and manages open source files being changed externally reasonably well, but it does not do the same for the project files.

 The simple solution is to close MPLAB-X and delete the nbprojectprivate directory.  The project can then be opened again in MPLAB-X, as it will re-generate it’s private files (as it should anyway).

MikeAtCalidus

Junior Member

  • Total Posts : 77
  • Reward points : 0
  • Joined: 2013/02/14 03:20:04
  • Status: offline

Re: Errors while reading XML from …


2014/05/22 07:23:43

(permalink)

Ok, so the fix above works for my library components, but not for the executable that uses them.  Nor do any of the suggestions in the threads below solve the issue:

  It looks like I’m going to have to clone my repository again from fresh and see if the problem goes away.

 Has anyone had any similar problems using other variants of netbeans?  Or is this a problem specific to MPLAB-X?

MikeAtCalidus

Junior Member

  • Total Posts : 77
  • Reward points : 0
  • Joined: 2013/02/14 03:20:04
  • Status: offline

Re: Errors while reading XML from …


2014/05/22 07:45:00

(permalink)

It looks as if Netbeans has be plagued with similar issues for quite some time.

 But reading the bug reports suggests that these are not entirely the same as the issue I’m experiencing.

post edited by MikeAtCalidus — 2014/05/22 07:53:13

MikeAtCalidus

Junior Member

  • Total Posts : 77
  • Reward points : 0
  • Joined: 2013/02/14 03:20:04
  • Status: offline

Re: Errors while reading XML from …


2014/05/22 07:47:37

(permalink)

Now my links aren’t showing in my posts.  ~grrrs~

 «Some restrictions apply to prevent link (URL) Spam.»

post edited by MikeAtCalidus — 2014/05/22 07:54:24

MikeAtCalidus

Junior Member

  • Total Posts : 77
  • Reward points : 0
  • Joined: 2013/02/14 03:20:04
  • Status: offline

Re: Errors while reading XML from …


2014/05/22 07:49:51

(permalink)

netbeans.org/bugzilla/show_bug.cgi?id=231582
netbeans.org/bugzilla/show_bug.cgi?id=151273
netbeans.org/bugzilla/show_bug.cgi?id=182321

 Or FWSE for «netbeans Errors while reading XML».

post edited by MikeAtCalidus — 2014/05/22 07:52:02

Jose Diaz

Administrator

  • Total Posts : 1676
  • Reward points : 0
  • Joined: 2010/06/23 11:10:56
  • Location: 0
  • Status: offline

Re: Errors while reading XML from …


2014/05/22 08:29:47

(permalink)

Please read the section «5.19, CONTROL SOURCE CODE» in $inst_dir_mplabx/docs/MPLAB_X_IDE_Users_Guide.pdf. It explains what files need to go into your repository.

«Netbeans, is poor in the way it manages .mk files, but that’s a»

For example, the *.mk files are not needed in revision control since they are regenerated as needed. They can actually even be regenerated outside of the IDE if you want to autmate testing. The directory nbproject/private is not to be committed either. If you follow the guidelines in section 5.19, you will avoid most issues. However, the file nbproject/configurations.xml should be under version control. And it might be that a conflict happens when merging this file. The conflict will make the xml be non-valid and you will get the error of an ‘error while reading xml’. In that case, close the project (if it completes opening), you can open the xml with MPLAB X itself and right click on the file, select ‘check xml’. Fix the conflict, close the file and reopen the project. Or you can fix the xml outside MPLAB X.
Jose

jeff_d

Starting Member

  • Total Posts : 58
  • Reward points : 0
  • Joined: 2017/12/11 08:49:30
  • Location: 0
  • Status: offline

Re: Errors while reading XML from …


2018/01/29 08:47:55

(permalink)

Jose Diaz
Please read the section «5.19, CONTROL SOURCE CODE» in $inst_dir_mplabx/docs/MPLAB_X_IDE_Users_Guide.pdf. It explains what files need to go into your repository.

«Netbeans, is poor in the way it manages .mk files, but that’s a»

For example, the *.mk files are not needed in revision control since they are regenerated as needed. They can actually even be regenerated outside of the IDE if you want to autmate testing. The directory nbproject/private is not to be committed either. If you follow the guidelines in section 5.19, you will avoid most issues. However, the file nbproject/configurations.xml should be under version control. And it might be that a conflict happens when merging this file. The conflict will make the xml be non-valid and you will get the error of an ‘error while reading xml’. In that case, close the project (if it completes opening), you can open the xml with MPLAB X itself and right click on the file, select ‘check xml’. Fix the conflict, close the file and reopen the project. Or you can fix the xml outside MPLAB X.
Jose
 

That’s exactly how my repo is setup and I just encountered this same problem with the IDE (v3.10) using git. Did everything to confirm the files in nbproject directory are current, still got the xml error. Deleting private directory seems to have restored things to normal.

 Diffing the problem xml files seems I renamed a configuration (which is saved in the private direcotry and not part of the repo), this conf name mis-match was the problem. Is there a reason why the IDE can’t treat the private directory files as children and recreate them when they don’t sync with the parent in nbproject directory?

 @MikeAtCalidus Thanks for the fix!

jeff_d

Starting Member

  • Total Posts : 58
  • Reward points : 0
  • Joined: 2017/12/11 08:49:30
  • Location: 0
  • Status: offline

Re: Errors while reading XML from …


2018/01/29 08:51:29

(permalink)

Couldn’t edit my own post, server says I’m restricted from doing so… wanted to add there was no merge conflicts in the xml files, just different value for the «conf name» token between the nbprojectconfigurations.xml and nbprojectprivateconfigurations.xml.

JoshuaHartwig

Super Member

  • Total Posts : 357
  • Reward points : 0
  • Joined: 2014/02/10 10:58:13
  • Location: 0
  • Status: offline

Re: Errors while reading XML from …


2018/01/29 11:11:18

(permalink)

I believe this issue is specifically about startup conditions for the IDE.  When the IDE loads a project, it wants to set the build configuration from your private directory.  The private directory is your computer’s settings for that project (and thus not a child of the project itself).  You are a developer.  You last had the IDE open with that configuration set.  Why wouldn’t you want that same build configuration?

 However, if you have been editing the build configurations outside of the IDE (e.g. git), and that particular configuration no longer exists, the IDE throws its hands in the air in frustration.

 This is an annoying bug, and I agree that it should not still be a problem, but at least the fix is easy: open the privateconfigurations.xml and change the build configuration to an existing configuration.

MPLab X red squiggles can lie.  What does the Compiler output say?
XC8 update missing PLIBs?  Now are a separate download.  Code Configurator recommended for new projects.

  1. Default Error while reading an XML

    i have already made an xml.
    but when i m reading it it shows error while setiing in device.

    my code is:—

    void XMLReader::read(QString fileName) //// file name is the xml name
    {
    QFile xmlFile(fileName);
    xmlFile.open(QIODevice::ReadOnly);

    qDebug()<<«///////////////////////////»<<xmlFile.isOpen(); ——>> shows its open

    xml.setDevice(&xmlFile); ——>> shows error here

    if (xml.readNextStartElement() && xml.name() == «Summary»)
    processSummary();

    if (xml.tokenType() == QXmlStreamReader::Invalid)
    xml.readNext();

    if (xml.hasError()) {
    xml.raiseError();
    qDebug() << «error» << endl;
    }

    }

    void XMLReader:rocessSummary()
    {
    if(!xml.isStartElement() || xml.name()!= «Summary»)
    return;

    QString blankspaces;
    QString blanklines;
    QString words;
    QString with_hash;

    while (xml.readNextStartElement()) {
    if (xml.name() == «no_of_blank_spaces»)
    blankspaces=xml.text().toString();
    if (xml.name() == «no_of_blank_lines»)
    blanklines=xml.text().toString();
    if (xml.name() == «no_of_words»)
    words=xml.text().toString();
    if (xml.name() == «no_of_lines_starting_with_hash»)
    with_hash= xml.text().toString();

    }
    qDebug()<<«please answer» <<blankspaces << endl;

    }

    my XML is—

    <?xml version=»1.0″ encoding=»UTF-8″?>
    <Summary>
    <no_of_blank_spaces>13</no_of_blank_spaces>
    <no_of_blank_lines>8</no_of_blank_lines>
    <no_of_words>16</no_of_words>
    <no_of_lines_starting_with_hash>2</no_of_lines_starting_with_hash>
    </Summary>

    it shos the output «»error»»..

    please help


  2. Default Re: Error while reading an XML

    What is the error you get ???


  3. Default Re: Error while reading an XML

    i get the output as ERROR from this code—

    if (xml.hasError()) {
    xml.raiseError();
    qDebug() << «error» << endl;
    }


  4. Default Re: Error while reading an XML

    I am not able to set content in qdomdocument.


@opatrascoiu

Hi,

I am getting an exception when reading the latest version of the test cases files (file 0083-feel-unicode-test-01) see below. The cause is the commented out tests for substring.

Raised this issue to make sure we don’t forget to investigate.

javax.xml.bind.UnmarshalException

  • with linked exception:
    [org.xml.sax.SAXParseException; lineNumber: 118; columnNumber: 52; An invalid XML character (Unicode: 0xd83d) was found in the comment.]
    at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:335)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:563)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:249)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:214)
    at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:157)
    at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:204)
    at org.omg.dmn.tck.marshaller.TckMarshallingHelper.load(TckMarshallingHelper.java:36)
    at org.omg.dmn.tck.runner.junit4.DmnTckRunner.(DmnTckRunner.java:57)
    at org.omg.dmn.tck.runner.junit4.DmnTckSuite.(DmnTckSuite.java:80)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    Caused by: org.xml.sax.SAXParseException; lineNumber: 118; columnNumber: 52; An invalid XML character (Unicode: 0xd83d) was found in the comment.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1438)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanComment(XMLScanner.java:789)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanComment(XMLDocumentFragmentScannerImpl.java:1039)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2985)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:118)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:243)
    … 20 more
    java.lang.NullPointerException
    at java.util.concurrent.ConcurrentLinkedQueue.checkNotNull(ConcurrentLinkedQueue.java:914)
    at java.util.concurrent.ConcurrentLinkedQueue.offer(ConcurrentLinkedQueue.java:327)
    at java.util.concurrent.ConcurrentLinkedQueue.add(ConcurrentLinkedQueue.java:297)
    at org.junit.runner.Description.addChild(Description.java:182)
    at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:352)
    at com.intellij.junit4.JUnit4IdeaTestRunner.getDescription(JUnit4IdeaTestRunner.java:78)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:50)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Process finished with exit code -2

@tarilabs

Which JDK are you running this on, please?

I am asking as both on my local machine (JDK8) and Travis CI does not exhibit this issue despite I confirmed they do pass through

at org.omg.dmn.tck.marshaller.TckMarshallingHelper.load(TckMarshallingHelper.java:36)
at org.omg.dmn.tck.runner.junit4.DmnTckRunner.(DmnTckRunner.java:57)
at org.omg.dmn.tck.runner.junit4.DmnTckSuite.(DmnTckSuite.java:80)

I can sure move the commented-out tests in a non-compliant folder if this is causing troubles, but was worthy to ask this question to try understand if it’s a local problem or environment problem, first.

@opatrascoiu



Copy link


Contributor

Author

java version «1.8.0_191»
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

on Windows. Investigating …

@opatrascoiu



Copy link


Contributor

Author

The reported error

[org.xml.sax.SAXParseException; lineNumber: 118; columnNumber: 52; An invalid XML character (Unicode: 0xd83d) was found in the comment.]

is valid, based on the specification of the the XML comments. The allowed set of characters comments is

Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */

See https://www.w3.org/TR/REC-xml/#sec-comments).

Not sure why the error is not reported in other envs.

tarilabs

added a commit
to tarilabs/dmn-tck
that referenced
this issue

May 15, 2019

@tarilabs

@tarilabs

tarilabs

added a commit
that referenced
this issue

May 15, 2019

@tarilabs

#305)

... ignoring UTF-8 encoding.
ref #299

@opatrascoiu



Copy link


Contributor

Author

I tried to force the encoding to UTF-8 same errors.The bottom line is the file was incorrect (incorrect encoding).

Thanks for fixing it.

Just curious, was the error reported by Travis CI?

@tarilabs

The bottom line is the file was incorrect (incorrect encoding).
Thanks for fixing it.

I stand by the motivation detailed in UTF-8 Vs UTF-16 encoding I detailed in #299 (comment) and I don’t think I fixed something, we just circumvented the problem for an environment which in my perspective is not respecting the xml prolog, ..or maybe Git on Windows is playing a role here in messing with the encoding? Just an idea..

was the error reported by Travis CI?

No error on Travis CI, as mentioned #299 (comment)
You can also double-verify by checking on the little Travis icons near commits or on the main Travis page.

@opatrascoiu



Copy link


Contributor

Author

Replacing manually the characters with UTF-8 encoding works. For example,

            <expected>
                <value xsi:type="xsd:string">xF0x9Fx98x80</value>
            </expected>

We should probably use the UTF-8 encoding for this kind of characters to avoid issues like this. After all, the encoding at the top of the file is UTF-8.

@tarilabs

Cool idea!
But for xml we should escape it with the markup escape sequence, I mean using the &# way not with x, do you agree or have I missed something, please?

@opatrascoiu



Copy link


Contributor

Author

Even better with &#x1234 :)

Понравилась статья? Поделить с друзьями:
  • Error while reading line from the server
  • Error while reading hw number перевод
  • Error while reading hw number kess v2
  • Error while reading font fonts russian consolefont
  • Error while reading font fonts console font