[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug xml/26652] New: XML parsing fails on encoding problem
From: |
egon dot willighagen at gmail dot com |
Subject: |
[Bug xml/26652] New: XML parsing fails on encoding problem |
Date: |
12 Mar 2006 15:29:32 -0000 |
Ok, to start with the start: JChemPaint did no longer work with 0.90 while it
did with 0.21. After bugging Roman Kennke, it turned out to be a XML reading
problem, which got me here.
I stripped down the code, and I think the following reproduces the bug to the
core:
import java.io.*;
import org.xml.sax.*;
public class XMLErrorTest {
public static void main(String[] args) {
try {
javax.xml.parsers.SAXParserFactory spf =
javax.xml.parsers.SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
javax.xml.parsers.SAXParser saxParser = spf.newSAXParser();
XMLReader parser = saxParser.getXMLReader();
parser.setFeature("http://xml.org/sax/features/validation", false);
Reader input = new FileReader("src/data/templates/list_aminoacids.cml");
parser.parse(new InputSource(input));
System.out.println("Parsing succeeded");
} catch (Exception e) {
System.out.println("Error while reading XML: " + e.getMessage());
e.printStackTrace();
}
}
}
The XML on which it fails can be found in CDK CVS here:
http://cvs.sourceforge.net/viewcvs.py/cdk/cdk/src/data/templates/list_aminoacids.cml
Though the problem is the first line. So the below XML source gives the same
error. Removing the first line will make the file get parsed without trouble.
<?xml version="1.0" encoding="ISO-8859-1"?>
<list title="List of amino acids"
xmlns="http://www.xml-cml.org/schema/cml2/core">
<molecule id="alanine" dictRef="pdb:aminoAcid">
<name>alanine</name>
<name dictRef="pdb:residueName">Ala</name>
<name dictRef="pdb:oneLetterCode">A</name>
<scalar dictRef="pdb:id">3</scalar>
<atomArray>
<atom id="a1" elementType="C" x2="265.0" y2="989.0"/>
<atom id="a2" elementType="N" x2="234.0" y2="972.0"
dictRef="pdb:nTerminus"/>
<atom id="a3" elementType="C" x2="265.0" y2="1025.0"/>
<atom id="a4" elementType="C" x2="296.0" y2="971.0"
dictRef="pdb:cTerminus"/>
<atom id="a5" elementType="O" x2="296.0" y2="935.0"/>
<atom id="a6" elementType="O" x2="327.0" y2="988.0"/>
</atomArray>
<bondArray>
<bond id="b1" atomRefs2="a2 a1" order="S"/>
<bond id="b2" atomRefs2="a1 a3" order="S"/>
<bond id="b3" atomRefs2="a1 a4" order="S"/>
<bond id="b4" atomRefs2="a4 a5" order="D"/>
<bond id="b5" atomRefs2="a4 a6" order="S"/>
</bondArray>
</molecule>
</list>
The error I get is:
Error while reading XML: null
org.xml.sax.SAXParseException
at gnu.xml.stream.SAXParser.parse (SAXParser.java:660)
at XMLErrorTest.main (XMLErrorTest.java:16)
Caused by: javax.xml.stream.XMLStreamException
at gnu.xml.stream.XMLParser.next (XMLParser.java:1184)
at gnu.xml.stream.XMLParser.hasNext (XMLParser.java:984)
at gnu.xml.stream.SAXParser.parse (SAXParser.java:377)
...1 more
Caused by: java.io.UnsupportedEncodingException: document is not in its
declared encoding UTF-8: ISO-8859-1
at gnu.xml.stream.XMLParser$Input.setInputEncoding (XMLParser.java:5246)
at gnu.xml.stream.XMLParser.readXMLDecl (XMLParser.java:1718)
at gnu.xml.stream.XMLParser.next (XMLParser.java:1121)
...3 more
Egon
--
Summary: XML parsing fails on encoding problem
Product: classpath
Version: 0.90
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: xml
AssignedTo: dog at gnu dot org
ReportedBy: egon dot willighagen at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26652
- [Bug xml/26652] New: XML parsing fails on encoding problem,
egon dot willighagen at gmail dot com <=