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

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

import java.util.Map;

import static org.zwobble.mammoth.internal.util.Lists.eagerMap;
import static org.zwobble.mammoth.internal.util.Maps.entry;
import static org.zwobble.mammoth.internal.util.Maps.toMap;

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");
        return new Relationship(relationshipId, target);
    }
}