{"record":{"id":"89911edeb36200ec","repo":"symfony/translation","slug":"unable-to-load-s-xlifffileloader","errorCode":null,"errorMessage":"Unable to load \"%s\": ","messagePattern":"Unable to load \"(.+?)\": ","errorType":"exception","errorClass":"InvalidResourceException","httpStatus":null,"severity":"error","filePath":"Loader/XliffFileLoader.php","lineNumber":59,"sourceCode":"            }\n\n            if (!file_exists($resource)) {\n                throw new NotFoundResourceException(\\sprintf('File \"%s\" not found.', $resource));\n            }\n\n            if (!is_file($resource)) {\n                throw new InvalidResourceException(\\sprintf('This is neither a file nor an XLIFF string \"%s\".', $resource));\n            }\n        }\n\n        try {\n            if ($this->isXmlString($resource)) {\n                $dom = XmlUtils::parse($resource);\n            } else {\n                $dom = XmlUtils::loadFile($resource);\n            }\n        } catch (\\InvalidArgumentException|XmlParsingException|InvalidXmlException $e) {\n            throw new InvalidResourceException(\\sprintf('Unable to load \"%s\": ', $resource).$e->getMessage(), $e->getCode(), $e);\n        }\n\n        if ($errors = XliffUtils::validateSchema($dom)) {\n            throw new InvalidResourceException(\\sprintf('Invalid resource provided: \"%s\"; Errors: ', $resource).XliffUtils::getErrorsAsString($errors));\n        }\n\n        $catalogue = new MessageCatalogue($locale);\n        $this->extract($dom, $catalogue, $domain);\n\n        if (is_file($resource) && class_exists(FileResource::class)) {\n            $catalogue->addResource(new FileResource($resource));\n        }\n\n        return $catalogue;\n    }\n\n    private function extract(\\DOMDocument $dom, MessageCatalogue $catalogue, string $domain): void\n    {","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Loader/XliffFileLoader.php#L41-L77","documentation":"XmlUtils::parse()/loadFile() failed to produce a DOM document (malformed XML, unreadable file, or invalid XML); the loader wraps the underlying exception (InvalidArgumentException, XmlParsingException, or InvalidXmlException) in an InvalidResourceException with this prefix. The original message is appended after the colon.","triggerScenarios":"Calling XliffFileLoader::load() with an XLIFF string or file containing syntactically invalid XML, or a file XmlUtils cannot load (unreadable permissions, encoding issues).","commonSituations":"Hand-edited XLIFF files with unclosed tags; files exported by third-party tools with invalid characters; truncated downloads; wrong file encoding (not UTF-8).","solutions":["Validate the XLIFF file with xmllint or an XML editor and fix syntax errors.","Read the chained exception message (after the colon) to locate the exact XML problem (line/column).","Re-export the file from the translation tool ensuring valid XML and UTF-8 encoding.","Run the schema validation separately (XliffUtils::validateSchema) to confirm XML well-formedness first."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"$xml = @file_get_contents($resource);\nif (false === $xml) { throw new \\RuntimeException('Unreadable resource'); }\nif (false === simplexml_load_string($xml)) { throw new \\RuntimeException('Malformed XML in '.$resource); }","typeGuard":null,"tryCatchPattern":"try {\n    $catalogue = $loader->load($resource, $locale);\n} catch (InvalidResourceException $e) {\n    $this->logger->error('XLIFF load failed', ['resource' => $resource, 'reason' => $e->getMessage(), 'previous' => $e->getPrevious()?->getMessage()]);\n    throw $e;\n}","preventionTips":["Always inspect $e->getPrevious() for the precise XML error (line/column).","Lint XLIFF files with xmllint in CI before shipping.","Export files in UTF-8 from translation tools.","Avoid hand-editing XLIFF without re-validating."],"tags":["php","xml","xliff","parse-error"],"backgroundTag":"xml-parse-error","analyzedSha":"ae9e8a51bc29780d63c7f9efd6005d7c875e100b","analyzedAt":"2026-09-15T22:29:15.305Z","contentChangedAt":"2026-09-15T22:29:15.305Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}