{"record":{"id":"c4ec501411173d96","repo":"JetBrains/intellij-community","slug":"unexpected-element-element-c4ec50","errorCode":null,"errorMessage":"unexpected element: {element}","messagePattern":"unexpected element: (.+?)","errorType":"exception","errorClass":"UnexpectedFormElementException","httpStatus":null,"severity":"error","filePath":"java/compiler/forms-compiler/src/com/intellij/uiDesigner/lw/LwRootContainer.java","lineNumber":47,"sourceCode":"  @Override\n  public String getClassToBind(){\n    return myClassToBind;\n  }\n\n  public void setClassToBind(final String classToBind) {\n    myClassToBind = classToBind;\n  }\n\n  @Override\n  public void read(final Element element, final PropertiesProvider provider) throws Exception {\n    if (element == null) {\n      throw new IllegalArgumentException(\"element cannot be null\");\n    }\n    if (!Utils.FORM_NAMESPACE.equals(element.getNamespace().getURI())) {\n      throw new AlienFormFileException();\n    }\n    if(!\"form\".equals(element.getName())){\n      throw new UnexpectedFormElementException(\"unexpected element: \"+element);\n    }\n\n    setId(\"root\");\n\n    myClassToBind = element.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_BIND_TO_CLASS);\n\n    // Constraints and properties\n    for (final Element child : element.getChildren()) {\n      if (child.getName().equals(UIFormXmlConstants.ELEMENT_BUTTON_GROUPS)) {\n        readButtonGroups(child);\n      }\n      else if (child.getName().equals(UIFormXmlConstants.ELEMENT_INSPECTION_SUPPRESSIONS)) {\n        readInspectionSuppressions(child);\n      }\n      else {\n        final LwComponent component = createComponentFromTag(child);\n        addComponent(component);\n        component.read(child, provider);","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/compiler/forms-compiler/src/com/intellij/uiDesigner/lw/LwRootContainer.java#L29-L65","documentation":"Thrown by LwRootContainer.read when the root element of a parsed form file has the right namespace (Utils.FORM_NAMESPACE) but is not named 'form'. The lightweight reader only accepts <form> as the document root; anything else with the designer namespace is a structural error and raises UnexpectedFormElementException with the offending element.","triggerScenarios":"Parsing an XML document whose root is, say, <forms> or <Form> (wrong case) while declaring the form namespace, so the namespace check passes but the name check fails. Also triggered when a non-form designer file (other tool's format borrowing the namespace) is fed to Utils.loadFormXml.","commonSituations":"Hand-created XML files with the designer namespace but a wrong root tag; accidental case mismatch 'Form' vs 'form'; pointing form-loading code at the wrong XML file (one that happens to use the same namespace).","solutions":["Rename the root element of the file to exactly <form xmlns=\"http://www.intellij.com/ui/forms\">.","Verify the code is loading the intended .form file path.","Let the GUI designer create/save the file so the root structure is canonical."],"exampleFix":"<!-- before -->\n<forms xmlns=\"http://www.intellij.com/ui/forms\"> ... </forms>\n\n<!-- after -->\n<form xmlns=\"http://www.intellij.com/ui/forms\"> ... </form>","handlingStrategy":"validation","validationCode":"// Pre-check the document root before handing it to the reader\nif (!\"form\".equals(rootElement.getName()) || !Utils.FORM_NAMESPACE.equals(rootElement.getNamespace().getURI())) {\n  throw new IllegalArgumentException(\"Not a GUI Designer form file: \" + fileName);\n}","typeGuard":null,"tryCatchPattern":"try { rootContainer.read(element, provider); } catch (UnexpectedFormElementException | AlienFormFileException e) { /* wrong root element or namespace: verify file path and root tag */ }","preventionTips":["Name the root exactly <form> in the designer namespace.","Double-check file paths passed to form loaders."],"tags":["gui-designer","form-xml","xml-parse","root-element"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}