Skip to content

Instantly share code, notes, and snippets.

@JogoShugh
Last active October 17, 2017 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JogoShugh/81cd60147b46694eecc8b2da0fb995eb to your computer and use it in GitHub Desktop.
Save JogoShugh/81cd60147b46694eecc8b2da0fb995eb to your computer and use it in GitHub Desktop.
Java XML Sax Error BWIN
<?xml version="1.0" encoding="UTF-8"?>
<Assets total="11166" pageSize="2147483647" pageStart="0">
<Asset href="/GVC-Sandbox/rest-1.v1/Data/Epic/3286021" id="Epic:3286021">
<Attribute name="Name">MTT General requirments</Attribute>
</Asset>
<Asset href="/GVC-Sandbox/rest-1.v1/Data/Epic/3220348" id="Epic:3220348">
<Attribute name="Name">GIT - a new SCM</Attribute>
</Asset>
<Asset href="/GVC-Sandbox/rest-1.v1/Data/Epic/3394297" id="Epic:3394297">
<Attribute name="Name">Sun Estate Refresh (Vienna) &#x13; Sun Maintenance</Attribute>
</Asset>
<Asset href="/GVC-Sandbox/rest-1.v1/Data/Epic/3205656" id="Epic:3205656">
<Attribute name="Name">New Jersey Achievements and Missions</Attribute>
</Asset>
<Asset href="/GVC-Sandbox/rest-1.v1/Data/Epic/3394304" id="Epic:3394304">
<Attribute name="Name">Partner Portal for Poker</Attribute>
</Asset>
<Asset href="/GVC-Sandbox/rest-1.v1/Data/Epic/3228489" id="Epic:3228489">
<Attribute name="Name">Side-bets</Attribute>
</Asset>
</Assets>
// Original file: https://github.com/versionone/VersionOne.SDK.Java.APIClient/blob/D-12784_URL_parsing_fix_with_manual_decoding_step_works_with_dates/src/main/java/com/versionone/apiclient/XMLHandler.java
public static DocumentBuilder createDocumentBuilder() throws ParserConfigurationException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringElementContentWhitespace(true);
factory.setExpandEntityReferences(false);
factory.setValidating(false);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder;
}
// used by:
public static Document buildDocument(Reader reader, String url) throws APIException, ConnectionException {
try {
DocumentBuilder builder = createDocumentBuilder();
InputSource is = new InputSource(reader);
is.setEncoding("UTF-8");
Document doc = builder.parse(is);
return doc;
} catch (ParserConfigurationException e) {
throw new APIException("Parser Configuration Error ", url, e);
} catch (IOException e) {
throw new ConnectionException("IO Error: "+url, e);
} catch (SAXException e) {
throw new APIException("SAX Error ", url, e);
}
finally {
if(null != reader){
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
[Fatal Error] :2:1182554: Character reference "&#
com.versionone.apiclient.exceptions.APIException: SAX Error : Epic?sel=Epic.Name,Epic.Number,Epic.CreateDate&where=Epic.CreateDate<'2016-01-01'
at com.versionone.apiclient.XMLHandler.buildDocument(XMLHandler.java:42)
at com.versionone.apiclient.Services.retrieve(Services.java:137)
at TestV1.testFilter(TestV1.java:87)
at TestV1.main(TestV1.java:31)
Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 1182554; Character reference "&#
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at com.versionone.apiclient.XMLHandler.buildDocument(XMLHandler.java:34)
... 3 more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment