{"record":{"id":"a819ce0a4cd8f069","repo":"symfony/translation","slug":"not-a-valid-xliff-namespace-s","errorCode":null,"errorMessage":"Not a valid XLIFF namespace \"%s\".","messagePattern":"Not a valid XLIFF namespace \"(.+?)\"\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Util/XliffUtils.php","lineNumber":43,"sourceCode":"    /**\n     * Gets xliff file version based on the root \"version\" attribute.\n     *\n     * Defaults to 1.2 for backwards compatibility.\n     *\n     * @throws InvalidArgumentException\n     */\n    public static function getVersionNumber(\\DOMDocument $dom): string\n    {\n        foreach ($dom->getElementsByTagName('xliff') as $xliff) {\n            $version = $xliff->attributes->getNamedItem('version');\n            if ($version) {\n                return $version->nodeValue;\n            }\n\n            $namespace = $xliff->attributes->getNamedItem('xmlns');\n            if ($namespace) {\n                if (0 !== substr_compare('urn:oasis:names:tc:xliff:document:', $namespace->nodeValue, 0, 34)) {\n                    throw new InvalidArgumentException(\\sprintf('Not a valid XLIFF namespace \"%s\".', $namespace));\n                }\n\n                return substr($namespace, 34);\n            }\n        }\n\n        // Falls back to v1.2\n        return '1.2';\n    }\n\n    /**\n     * Validates and parses the given file into a DOMDocument.\n     *\n     * @throws InvalidResourceException\n     */\n    public static function validateSchema(\\DOMDocument $dom): array\n    {\n        $xliffVersion = static::getVersionNumber($dom);","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Util/XliffUtils.php#L25-L61","documentation":"Thrown by XliffUtils::getVersionNumber() when an XLIFF file's root element has an xmlns attribute that does not start with 'urn:oasis:names:tc:xliff:document:'. The XLIFF loader detects the version from this namespace to pick the right schema and parser.","triggerScenarios":"Loading an XLIFF file whose root <xliff> element declares a different or malformed default namespace, e.g. generic 'http://...' namespaces or SVG/HTML documents saved as .xlf.","commonSituations":"Exporting XLIFF from a tool that writes non-standard namespaces, renaming an HTML/XML file to .xlf, or hand-written XLIFF with a wrong xmlns string.","solutions":["Fix the root element namespace to urn:oasis:names:tc:xliff:document:1.2 or :2.0/:2.1/:2.2","Re-export the file from the translation tool in a standard XLIFF format","Validate the file against the XLIFF XSD before loading"],"exampleFix":"// before\n<xliff xmlns=\"http://example.com/xliff\" version=\"1.2\">\n// after\n<xliff xmlns=\"urn:oasis:names:tc:xliff:document:1.2\" version=\"1.2\">","handlingStrategy":"validation","validationCode":"$xml = simplexml_load_file($file);\n$ns = (string) ($xml->getDocNamespaces()[''] ?? '');\nif (!str_starts_with($ns, 'urn:oasis:names:tc:xliff:document:')) {\n    throw new \\InvalidArgumentException(\"{$file} is not standard XLIFF.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    $translator->getCatalogue($locale);\n} catch (InvalidArgumentException $e) {\n    if (str_contains($e->getMessage(), 'Not a valid XLIFF namespace')) {\n        // fix or re-export the .xlf file\n    }\n}","preventionTips":["Validate .xlf files against the official XLIFF XSD in CI","Re-export from CAT tools as 'XLIFF 1.2' not a custom dialect","Never rename HTML/XML files to .xlf"],"tags":["php","symfony","translation","xliff","xml"],"backgroundTag":"invalid-argument-format","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"}