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

import org.zwobble.mammoth.xml.XmlElement;

import java.util.Map;

import static com.google.common.collect.Maps.immutableEntry;
import static org.zwobble.mammoth.util.MammothMaps.toMap;

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

    private static Map.Entry<String, Relationship> readRelationship(XmlElement element) {
        return immutableEntry(
            element.getAttribute("Id"),
            new Relationship(element.getAttribute("Target")));
    }
}