SubtitleEdit/subtitleedit · error · Exception

{e.Message}

Error message

{e.Message}

What it means

Thrown by DCinemaSmpte2010.ValidationCallBack during ToText export when the generated DCinema XML fails validation against SMPTE-428-7-2010-DCST.xsd. The validation event's message is re-thrown verbatim as a bare Exception, aborting the export. The 2010 schema is stricter than 2007 (e.g. requires EditRate, language attributes).

Source

Thrown at src/libse/SubtitleFormats/DCinemaSmpte2010.cs:626

                match = regex.Match(xml, match.Index);
            }

            regex = RegexWhiteSpaceTextCloseTag;
            match = regex.Match(xml);
            while (match.Success)
            {
                xml = xml
                    .Remove(match.Index, match.Value.Length)
                    .Insert(match.Index, match.Value.Trim());
                match = regex.Match(xml, match.Index);
            }

            return xml;
        }

        private void ValidationCallBack(object sender, ValidationEventArgs e)
        {
            throw new Exception(e.Message);
        }

        public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
        {
            _errorCount = 0;
            var sb = new StringBuilder();
            lines.ForEach(line => sb.AppendLine(line));
            var xml = new XmlDocument { XmlResolver = null };
            xml.LoadXml(sb.ToString().Replace("<dcst:", "<").Replace("</dcst:", "</").Replace("xmlns=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\"", string.Empty)); // tags might be prefixed with namespace (or not)... so we just remove them

            var ss = Configuration.Settings.SubtitleSettings;
            try
            {
                ss.InitializeDCinemaSettings(true);
                var node = xml.DocumentElement.SelectSingleNode("Id");
                if (node != null)
                {
                    ss.CurrentDCinemaSubtitleId = node.InnerText;

View on GitHub (pinned to 17a9f07487)

Solutions

  1. Inspect e.Message in the thrown exception for the exact schema violation and element path.
  2. Supply the missing required fields (EditRate, language, Font Size/Color) in the subtitle settings before export.
  3. Ensure every referenced FontId is declared in FontList.
  4. If strict 2010 compliance is not required, export as 2007 instead.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-validate against SMPTE-428-7-2010-DCST.xsd with a non-throwing handler
var schemas = new XmlSchemaSet();
schemas.Add(null, "SMPTE-428-7-2010-DCST.xsd");
var settings = new XmlReaderSettings { ValidationType = ValidationType.Schema, Schemas = schemas };
var errors = new List<string>();
settings.ValidationEventHandler += (s, e) => errors.Add(e.Message);
// serialize, then validate the serialized output before returning it to the user

Try / catch

try
{
    var text = format.ToText(subtitle, title);
}
catch (Exception ex) when (ex.Message.Contains("validation"))
{
    logger.Error(ex, "DCinema 2010 validation failed");
}

Prevention

When it happens

Trigger: Exporting to DCinema Interop 2010 XML with content that violates the schema — missing EditUnit, malformed UUID, Font without required Id/Size/Color, a Subtitle with no Text, or an AspectRatio/FontSize out of the permitted range.

Common situations: Subtitles originating from formats that lack metadata the 2010 schema mandates (EditRate, language); font or UUID mismatches; very long subtitle text.

Related errors


AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13). Data as JSON: /api/errors/192b6de11f5bdd5e. Report an issue: GitHub.