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

import org.zwobble.mammoth.internal.xml.XmlElement;

import static org.zwobble.mammoth.internal.util.Lists.eagerMap;

public class RelationshipsXml {
    public static Relationships readRelationshipsXmlElement(XmlElement element) {
        return new Relationships(eagerMap(
            element.findChildren("relationships:Relationship"),
            RelationshipsXml::readRelationship
        ));
    }

    private static Relationship readRelationship(XmlElement element) {
        String relationshipId = element.getAttribute("Id");
        String target = element.getAttribute("Target");
        String type = element.getAttribute("Type");
        return new Relationship(relationshipId, target, type);
    }
}