{"record":{"id":"49a73e991d4b3fa5","repo":"SubtitleEdit/subtitleedit","slug":"e-message","errorCode":null,"errorMessage":"{e.Message}","messagePattern":"\\{e\\.Message\\}","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/libse/SubtitleFormats/DCinemaSmpte2007.cs","lineNumber":591,"sourceCode":"                    xmld.LoadXml(result);\n                    using (var xr = XmlReader.Create(zip))\n                    {\n                        xmld.Schemas.Add(null, xr);\n                        xmld.Validate(ValidationCallBack);\n                    }\n                }\n                catch (Exception exception)\n                {\n                    Errors = \"Error validating xml via SMPTE-428-7-2007-DCST.xsd: \" + exception.Message;\n                }\n            }\n\n            return DCinemaSmpte2010.FixDcsTextSameLine(result);\n        }\n\n        private void ValidationCallBack(object sender, ValidationEventArgs e)\n        {\n            throw new Exception(e.Message);\n        }\n\n        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)\n        {\n            _errorCount = 0;\n            var sb = new StringBuilder();\n            lines.ForEach(line => sb.AppendLine(line));\n            var xml = new XmlDocument { XmlResolver = null };\n            xml.LoadXml(sb.ToString().Replace(\"<dcst:\", \"<\").Replace(\"</dcst:\", \"</\").Replace(\"xmlns=\\\"http://www.smpte-ra.org/schemas/428-7/2007/DCST\\\"\", string.Empty)); // tags might be prefixed with namespace (or not)... so we just remove them\n            var ss = Configuration.Settings.SubtitleSettings;\n            try\n            {\n                ss.InitializeDCinemaSettings(true);\n                XmlNode node = xml.DocumentElement.SelectSingleNode(\"Id\");\n                if (node != null)\n                {\n                    ss.CurrentDCinemaSubtitleId = node.InnerText;\n                }","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/libse/SubtitleFormats/DCinemaSmpte2007.cs#L573-L609","documentation":"Thrown by DCinemaSmpte2007.ValidationCallBack, an XML schema validation event handler attached during ToText export. When the generated DCinema XML fails validation against SMPTE-428-7-2007-DCST.xsd, the validator raises a ValidationEventArgs whose message is re-thrown as a bare Exception. This interrupts export and surfaces the schema violation.","triggerScenarios":"Exporting a subtitle to DCinema XML (Interop 2007) whose content violates the SMPTE 428-7 schema — e.g. a UUID in the wrong format, a Font element missing required attributes, a TimeCode or FontId that does not match the schema's pattern, or text exceeding the max length for a subtitle.","commonSituations":"Subtitles with unusual characters, missing required UUIDs, font references to undefined Font elements, or empty/mandatory fields. Most often the root cause is in the data fed to ToText, not the schema itself.","solutions":["Read the embedded e.Message — it identifies the exact schema rule violated and the offending element/attribute.","Fix the subtitle data (UUIDs, font ids, time codes) so it satisfies the rule.","Verify all referenced FontIds exist in the <FontList> and required attributes (Size, Color) are present.","Validate against the XSD manually with an external validator to iterate faster."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate DCinema XML against the XSD yourself to surface errors with detail\nvar schemas = new XmlSchemaSet();\nschemas.Add(null, \"SMPTE-428-7-2007-DCST.xsd\");\nvar settings = new XmlReaderSettings { ValidationType = ValidationType.Schema, Schemas = schemas };\nsettings.ValidationEventHandler += (s, e) => { /* collect e.Message without throwing */ };\nusing var reader = XmlReader.Create(xmlPath, settings);\nwhile (reader.Read()) { }","typeGuard":null,"tryCatchPattern":"try\n{\n    var text = format.ToText(subtitle, title);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"validation\"))\n{\n    // e.Message names the schema rule; fix the subtitle data accordingly\n    logger.Error(ex, \"DCinema 2007 validation failed\");\n}","preventionTips":["Ensure all FontIds are declared in FontList before export.","Generate UUIDs in the canonical urn:uuid format.","Validate against the XSD in a pre-pass that collects (not throws) errors."],"tags":["subtitle-format","dcinema","xml","schema-validation","smpte"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}