mirror of
https://github.com/docling-project/docling-core.git
synced 2026-11-18 20:27:00 +00:00
fix(doclang): emit a fillable empty_value only inside a field item
On the DocLang 0.9 base a CVAT empty_value directly in a legacy form group became <value class="fillable"> outside <field_item>, which the schema forbids (kv fixtures failed Schematron validation). The fillable value is now emitted only under a field item or field value; elsewhere empty_value stays plain text, as upstream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
945d9f16bf
commit
dced2fa8e6
1 file changed
+8
-4
@@ -1311,10 +1311,13 @@ class DocLangTextSerializer(BaseModel, BaseTextSerializer):
|
||||
wrap_open_token = f'<{tok.value} class="{item.kind}">'
|
||||
elif isinstance(item, FieldHeadingItem):
|
||||
wrap_open_token = DocLangVocabulary._create_field_heading_token(level=item.level)
|
||||
elif isinstance(item, TextItem) and item.label == DocItemLabel.EMPTY_VALUE:
|
||||
# CVAT empty_value / fillable_field. A parent field_value already
|
||||
# carries the tag; otherwise emit the fillable value itself.
|
||||
parent_item = item.parent.resolve(doc) if item.parent else None
|
||||
elif isinstance(item, TextItem) and item.label == DocItemLabel.EMPTY_VALUE and (
|
||||
isinstance(parent_item := (item.parent.resolve(doc) if item.parent else None), FieldValueItem | FieldItem)
|
||||
):
|
||||
# CVAT empty_value / fillable_field inside a field item. A parent field_value
|
||||
# already carries the tag; directly under the field item, emit the fillable
|
||||
# value itself. Elsewhere (e.g. a legacy <form> group) a <value> would sit
|
||||
# outside <field_item>, which DocLang forbids: such items stay plain text.
|
||||
if isinstance(parent_item, FieldValueItem):
|
||||
wrap_open_token = None
|
||||
else:
|
||||
@@ -1323,6 +1326,7 @@ class DocLangTextSerializer(BaseModel, BaseTextSerializer):
|
||||
elif isinstance(item, TextItem) and (
|
||||
item.label
|
||||
in [ # FIXME: Catch all ...
|
||||
DocItemLabel.EMPTY_VALUE, # outside a field item (e.g. legacy <form>): plain text, as upstream
|
||||
DocItemLabel.HANDWRITTEN_TEXT,
|
||||
DocItemLabel.PARAGRAPH,
|
||||
DocItemLabel.REFERENCE,
|
||||
|
||||
Reference in new issue
Block a user