{"record":{"id":"93d41b65d43bc3f2","repo":"symfony/translation","slug":"invalid-resource-provided-s-errors","errorCode":null,"errorMessage":"Invalid resource provided: \"%s\"; Errors: ","messagePattern":"Invalid resource provided: \"(.+?)\"; Errors: ","errorType":"exception","errorClass":"InvalidResourceException","httpStatus":null,"severity":"error","filePath":"Loader/XliffFileLoader.php","lineNumber":63,"sourceCode":"            }\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    {\n        $xliffVersion = XliffUtils::getVersionNumber($dom);\n\n        if ('1.2' === $xliffVersion) {\n            $this->extractXliff1($dom, $catalogue, $domain);","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Loader/XliffFileLoader.php#L45-L81","documentation":"The DOM parsed successfully but failed XLIFF schema validation via XliffUtils::validateSchema(); the loader throws InvalidResourceException listing all schema errors after this prefix. The file must be valid XLIFF 1.2 or 2.0 per its declared version.","triggerScenarios":"Calling XliffFileLoader::load() with XML that is well-formed but violates the XLIFF schema — wrong root element/namespace, invalid attributes, missing required units, or a version attribute not matching the actual structure.","commonSituations":"Files exported by custom tools with non-standard XLIFF; XLIFF 2.0 content declared as version 1.2 or vice versa; missing xliff namespace declarations; hand-built translation files.","solutions":["Read the appended XliffUtils::getErrorsAsString() output to see each schema violation.","Fix the file so it conforms to XLIFF 1.2 or 2.0 (correct root <xliff> with proper xmlns and version attributes).","Re-export from the CAT tool choosing a standard XLIFF profile.","Validate locally first with xmllint against the official XLIFF schema before loading."],"exampleFix":"// before\n<xliff version=\"1.2\"><file>...</file></xliff> <!-- missing xmlns -->\n// after\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\"><file>...</file></xliff>","handlingStrategy":"validation","validationCode":"$dom = \\Symfony\\Component\\Config\\Util\\XmlUtils::loadFile($resource);\nif ($errors = \\Symfony\\Component\\Translation\\Util\\XliffUtils::validateSchema($dom)) {\n    throw new \\RuntimeException(XliffUtils::getErrorsAsString($errors));\n}","typeGuard":null,"tryCatchPattern":"try {\n    $catalogue = $loader->load($resource, $locale);\n} catch (InvalidResourceException $e) {\n    if (str_contains($e->getMessage(), 'Invalid resource provided')) {\n        // surface XliffUtils::getErrorsAsString details to translators\n    }\n    throw $e;\n}","preventionTips":["Validate XLIFF against the official 1.2/2.0 schema in CI.","Ensure version attribute matches actual XLIFF structure and namespaces are declared.","Use standard CAT-tool export profiles, not hand-rolled XML."],"tags":["php","xliff","schema-validation"],"backgroundTag":"schema-validation-failed","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"}