{"record":{"id":"3345e106b79b48b8","repo":"qax-os/excelize","slug":"unexpected-child-of-attrvalbool","errorCode":null,"errorMessage":"unexpected child of attrValBool","messagePattern":"unexpected child of attrValBool","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":26,"sourceCode":"// Supports complex components by high compatibility, and provided streaming\n// API for generating or reading data from a worksheet with huge amounts of\n// data. This library needs Go version 1.25.0 or later.\n\npackage excelize\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"strings\"\n)\n\nvar (\n\t// ErrAddVBAProject defined the error message on add the VBA project in\n\t// the workbook.\n\tErrAddVBAProject = errors.New(\"unsupported VBA project\")\n\t// ErrAttrValBool defined the error message on marshal and unmarshal\n\t// boolean type XML attribute.\n\tErrAttrValBool = errors.New(\"unexpected child of attrValBool\")\n\t// ErrCellCharsLength defined the error message for receiving a cell\n\t// characters length that exceeds the limit.\n\tErrCellCharsLength = fmt.Errorf(\"cell value must be 0-%d characters\", TotalCellChars)\n\t// ErrCellStyles defined the error message on cell styles exceeds the limit.\n\tErrCellStyles = fmt.Errorf(\"the cell styles exceeds the %d limit\", MaxCellStyles)\n\t// ErrChartTitle defined the error message on both formula and rich text for\n\t// chart title.\n\tErrChartTitle = errors.New(\"cannot set both 'Formula' and 'Paragraph' for chart title\")\n\t// ErrColumnNumber defined the error message on receive an invalid column\n\t// number.\n\tErrColumnNumber = fmt.Errorf(\"the column number must be greater than or equal to %d and less than or equal to %d\", MinColumns, MaxColumns)\n\t// ErrColumnWidth defined the error message on receive an invalid column\n\t// width.\n\tErrColumnWidth = fmt.Errorf(\"the width of the column must be less than or equal to %d characters\", MaxColumnWidth)\n\t// ErrCoordinates defined the error message on invalid coordinates tuples\n\t// length.\n\tErrCoordinates = errors.New(\"coordinates length must be 4\")\n\t// ErrCustomNumFmt defined the error message on receive the empty custom","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L8-L44","documentation":"ErrAttrValBool is returned by the custom boolean XML attribute unmarshaler (attrValBool.UnmarshalXML) when it encounters an XML StartElement where only a simple character-data value was expected. The attrValBool type is meant to parse text like \"1\"/\"0\" or \"true\"/\"false\" into a bool, so child elements are invalid. It signals malformed XML content inside a spreadsheet document.","triggerScenarios":"Unmarshaling XML where an element mapped to attrValBool contains a nested child element (xml.StartElement) instead of plain text; typically when decoding a hand-edited, third-party-generated, or corrupted xlsx part.","commonSituations":"Opening spreadsheets produced by non-Excel tools that emit nested tags inside boolean attributes; manual XML editing of sheet/styles parts; fuzzed or truncated files fed to f.Styles() or other internal XML decoding paths.","solutions":["Fix the source XML so boolean elements contain only text (e.g. <b>true</b>), removing any nested child elements","Regenerate the file with Excel or a compliant producer instead of hand-editing XML","Sanitize/normalize the offending XML part before opening with the library","If you cannot control the file, pre-validate the XML or report the malformed source to its producer"],"exampleFix":"// before (XML)\n<applyFont><b>1</b></applyFont>\n// after (XML)\n<applyFont>1</applyFont>","handlingStrategy":"try-catch","validationCode":"// Pre-scan the XML part for nested elements inside simple-text nodes:\n// decoder.Token() returning xml.StartElement where a chardata bool was expected means the file is malformed.","typeGuard":null,"tryCatchPattern":"_, err := f.Styles()\nif errors.Is(err, excelize.ErrAttrValBool) {\n    // reject or sanitize the malformed XML source before retrying\n}","preventionTips":["Do not hand-edit xlsx XML parts","Prefer files produced by Excel or compliant libraries","Fuzz/sanity-check third-party spreadsheets before decoding","Keep the library updated; unmarshaler handling may improve"],"tags":["xml","unmarshal","boolean"],"backgroundTag":"schema-validation-failed","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}