{"record":{"id":"98d63e940bbe9873","repo":"apache/maven","slug":"unrecognised-tag-98d63e","errorCode":null,"errorMessage":"Unrecognised tag: '{}'","messagePattern":"Unrecognised tag: '(.+?)'","errorType":"exception","errorClass":"XMLStreamException","httpStatus":null,"severity":"error","filePath":"src/mdo/reader.vm","lineNumber":718,"sourceCode":"        // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too\n        if (strict) {\n            throw new XMLStreamException(\"Unknown attribute '\" + attribute + \"' for tag '\" + tagName + \"'\", parser.getLocation(), null);\n        }\n    } //-- void checkUnknownAttribute(XMLStreamReader, String, String, boolean)\n\n    /**\n     * Method checkUnknownElement.\n     *\n     * @param parser a parser object.\n     * @param strict a strict object.\n     * @throws XMLStreamException XMLStreamException if\n     * any.\n     * @throws IOException IOException if any.\n     */\n    private void checkUnknownElement(XMLStreamReader parser, boolean strict)\n        throws XMLStreamException, IOException {\n        if (strict) {\n            throw new XMLStreamException(\"Unrecognised tag: '\" + parser.getLocalName() + \"'\", parser.getLocation(), null);\n        }\n\n        for (int unrecognizedTagCount = 1; unrecognizedTagCount > 0;) {\n            int eventType = parser.next();\n            if (eventType == XMLStreamReader.START_ELEMENT) {\n                unrecognizedTagCount++;\n            } else if (eventType == XMLStreamReader.END_ELEMENT) {\n                unrecognizedTagCount--;\n            }\n        }\n    } //-- void checkUnknownElement(XMLStreamReader, boolean)\n\n    /**\n     * Returns the state of the \"add default entities\" flag.\n     *\n     * @return boolean\n     */\n    public boolean getAddDefaultEntities() {","sourceCodeStart":700,"sourceCodeEnd":736,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/src/mdo/reader.vm#L700-L736","documentation":"checkUnknownElement in the classic reader.vm template: a child element matching no field of the parsed class throws in strict mode with the element's local name. In lenient mode it skips the whole unrecognized subtree with a depth counter driven by parser.next() (the stax variant uses the nextTag helper instead) - same effect: non-strict reads drop unknown content instead of failing.","triggerScenarios":"Strict read of documents with elements unknown to the reader's model: newer-schema features with an older reader, misspelled tags, custom extension elements.","commonSituations":"Version skew between document and generated reader; hand-editing typos; third-party tools injecting proprietary elements.","solutions":["Fix or remove the unrecognized element - message and location give name and position.","Upgrade to a library version whose model knows the element.","Check spelling/casing against the model docs.","Read with strict=false when unknown elements must be tolerated (subtrees are skipped)."],"exampleFix":"<!-- before -->\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\">\n  <dependencys>...</dependencys>\n</project>\n\n<!-- after -->\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\">\n  <dependencies>...</dependencies>\n</project>","handlingStrategy":"fallback","validationCode":"// XSD validation reports unknown elements before the strict read\nSchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);\nsf.newSchema(new StreamSource(xsdFile)).newValidator().validate(new StreamSource(xmlFile));","typeGuard":"static boolean isUnknownElement(XMLStreamException e) {\n    return e.getMessage() != null && e.getMessage().startsWith(\"Unrecognised tag\");\n}","tryCatchPattern":"byte[] bytes = in.readAllBytes();\ntry {\n    Model model = reader.read(new ByteArrayInputStream(bytes), true);\n} catch (XMLStreamException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unrecognised tag\")) {\n        // tolerated: lenient re-parse skips unknown elements and their subtrees\n        Model model = reader.read(new ByteArrayInputStream(bytes), false);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Align document schema versions with the reader's library version.","Validate against the XSD before strict reads.","Reject documents from unknown producers at intake."],"tags":["xml","stax","unknown-element","strict-mode","schema-validation"],"backgroundTag":"xml-unknown-element","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}