Skip to content

DocLang output omits the namespace by default, so save_as_doclang_archive(validate=True) fails on any document #783

Description

@DavidPivert

DocLangParams.include_namespace defaults to False, so every DocLang produced by docling-core starts with <doclang version="0.7"> without xmlns="https://www.doclang.ai/ns/v0". The reference toolkit's XSD requires the namespace, which means docling-core's own validated archive export fails on a trivial document:

import tempfile
from docling_core.types.doc import DoclingDocument

d = DoclingDocument(name="t")
d.add_text(label="text", text="Hello")
d.save_as_doclang_archive(filename=tempfile.mkdtemp() + "/t.dclx", validate=True)
doclang.validation.ValidationError: XSD validation failed:
  Line 1: Element 'doclang': No matching global declaration available for the validation root.

Same with the CLI on export_to_doclang() output: doclang validate out.dclg fails (passes only with -n / --allow-empty-namespace), and doclang pack out.dclg --validate fails with no option to allow an empty namespace.

Suggestion: default include_namespace to True, or at least force it in save_as_doclang_archive() (the .dclx format requires a valid DocLang document.xml). Keeping it off for token-lean model input still makes sense, but as an opt-out.

Versions: docling-core 2.97.1 (also checked on main), doclang 0.7.3, Python 3.12, macOS.
Workaround we use: inject xmlns into the root before writing the file.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions