aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/mammoth/docx/DocumentXmlReader.java
blob: 2d7bec0922ee9529a770dd05554416bf4d209486 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package org.zwobble.mammoth.docx;

import org.zwobble.mammoth.results.Result;
import org.zwobble.mammoth.documents.Document;
import org.zwobble.mammoth.xml.XmlElement;

public class DocumentXmlReader {
    private final BodyXmlReader bodyReader;

    public DocumentXmlReader(BodyXmlReader bodyReader) {
        this.bodyReader = bodyReader;
    }

    public Result<Document> readElement(XmlElement element) {
        XmlElement body = element.findChild("w:body");
        return bodyReader.readElements(body.children())
            .toResult()
            .map(Document::new);
    }
}