{"record":{"id":"c011570390c20a91","repo":"languagetool-org/languagetool","slug":"could-not-parse-xml-completewikicontent","errorCode":null,"errorMessage":"Could not parse XML: + completeWikiContent","messagePattern":"Could not parse XML: \\+ completeWikiContent","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/WikipediaQuickCheck.java","lineNumber":229,"sourceCode":"    return wikiContent\n        .replaceAll(\"\\\\[\\\\[[a-z]{2,6}:.*?\\\\]\\\\]\", \"\")\n        // category links\n        .replaceAll(\n            \"\\\\[\\\\[:?(Category|Categoria|Categoría|Catégorie|Kategorie):.*?\\\\]\\\\]\", \"\")\n        // file links, keeps alt and caption\n        .replaceAll(\n            \"(File|Fitxer|Fichero|Ficheiro|Fichier|Datei):.*?\\\\.(png|jpg|svg|jpeg|tiff|gif|PNG|JPG|SVG|JPEG|TIFF|GIF)\\\\|((thumb|miniatur)\\\\|)?((right|left)\\\\|)?\", \"\");\n  }\n\n  private MediaWikiContent getRevisionContent(String completeWikiContent) {\n    SAXParserFactory factory = SAXParserFactory.newInstance();\n    SAXParser saxParser;\n    RevisionContentHandler handler = new RevisionContentHandler();\n    try {\n      saxParser = factory.newSAXParser();\n      saxParser.parse(new InputSource(new StringReader(completeWikiContent)), handler);\n    } catch (Exception e) {\n      throw new RuntimeException(\"Could not parse XML: \" + completeWikiContent, e);\n    }\n    return new MediaWikiContent(handler.getRevisionContent(), handler.getTimestamp());\n  }\n\n  private MultiThreadedJLanguageTool getLanguageTool(Language lang) throws IOException {\n    MultiThreadedJLanguageTool lt = new MultiThreadedJLanguageTool(lang);\n    enableWikipediaRules(lt);\n    for (String disabledRuleId : disabledRuleIds) {\n      lt.disableRule(disabledRuleId);\n    }\n    if (ngramDir != null) {\n      lt.activateLanguageModelRules(ngramDir);\n    }\n    disableSpellingRules(lt);\n    return lt;\n  }\n\n  private void enableWikipediaRules(JLanguageTool lt) {","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/WikipediaQuickCheck.java#L211-L247","documentation":"Parsing guard in getRevisionContent: the XML fetched from the MediaWiki API could not be parsed by the SAX parser, i.e. the response is not the expected MediaWiki export/rev format (API error page, HTML, truncated body).","triggerScenarios":"Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/WikipediaQuickCheck.java:229 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the fetched XML around the failure point","Check the MediaWiki API endpoint and parameters are correct","Handle API error responses before parsing"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}