docling
docling copied to clipboard
JATS: quote attributions, speakers and statement labels are dropped
Bug
The JATS backend only emits text that sits in a <p>. Text in these elements is not in a <p>, so it is dropped:
- the
<attrib>of a<disp-quote>(who is quoted), - the
<speaker>of a<speech>, - the
<label>and<title>of a<statement>, e.g. "Theorem 1".
Steps to reproduce
from io import BytesIO
from docling.datamodel.base_models import DocumentStream, InputFormat
from docling.document_converter import DocumentConverter
JATS = b"""<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.2 20190208//EN" "JATS-archivearticle1.dtd">
<article>
<front><article-meta><title-group><article-title>T</article-title></title-group></article-meta></front>
<body>
<sec><title>S</title>
<disp-quote><p>To be or not to be.</p><attrib>Shakespeare</attrib></disp-quote>
<speech><speaker>Alice</speaker><p>Hello there.</p></speech>
<statement><label>Theorem 1</label><title>Main</title><p>Every x is y.</p></statement>
</sec>
</body></article>"""
doc = DocumentConverter(allowed_formats=[InputFormat.XML_JATS]).convert(
DocumentStream(name="t.nxml", stream=BytesIO(JATS))
).document
print(doc.export_to_markdown())
Actual
# T
## S
To be or not to be.
Hello there.
Every x is y.
Expected
# T
## S
To be or not to be.
Shakespeare
Alice
Hello there.
Theorem 1
Main
Every x is y.
Versions
- docling
main@ 9b3ebca2 - Python 3.12, macOS 15
I have a fix with tests and will open a PR right after this.
Classification labels added: bug, priority:medium, jats.
These labels are advisory. Maintainers can correct them. The workflow preserves these corrections.