NLdoc.Conversion.Reader.Docx.Files.Relationship (NLdoc.Conversion.Reader.Docx v1.0.43)

View Source

This module provides functions for reading and parsing relationships files (e.g. word/_rels/document.xml.rels) into a map mapping {id, type} tuples to NLdoc.Conversion.Reader.Docx.AST.Relationship structs.

Summary

Functions

Get a relationship by its ID and type from a parsed map of relationships. The type can be a string equal to the relationship's Type attribute, or one of the atoms :hyperlink or :image to match their respective types.

Get the target of a relationship by its ID and type from a parsed map of relationships. The type can be a string equal to the relationship's Type attribute, or one of the atoms :hyperlink or :image to match their respective types.

Parses the contents of a relationships file (a Relationships XML element) into a map mapping {id, type} tuples to NLdoc.Conversion.Reader.Docx.Files.Relationship structs.

Reads a Docx relationships (.xml.rels) file at the given path and parses it into a single map as returned by parse/1.

Types

rel_type()

@type rel_type() :: String.t() | :hyperlink | :image

t()

@type t() :: %{
  required({id :: String.t(), type :: rel_type()}) =>
    relation :: NLdoc.Conversion.Reader.Docx.AST.Relationship.t()
}

Functions

get(rels, id, type, default \\ nil)

@spec get(t(), id :: nil, type :: rel_type(), default :: default) :: default
when default: var
@spec get(t(), id :: String.t(), type :: rel_type(), default :: default) ::
  NLdoc.Conversion.Reader.Docx.AST.Relationship.t() | default
when default: var

Get a relationship by its ID and type from a parsed map of relationships. The type can be a string equal to the relationship's Type attribute, or one of the atoms :hyperlink or :image to match their respective types.

get_target(rels, id, type, default \\ nil)

@spec get_target(t(), id :: nil, type :: rel_type(), default :: default) :: default
when default: var
@spec get_target(t(), id :: String.t(), type :: rel_type(), default :: default) ::
  String.t() | default
when default: var

Get the target of a relationship by its ID and type from a parsed map of relationships. The type can be a string equal to the relationship's Type attribute, or one of the atoms :hyperlink or :image to match their respective types.

parse(arg1)

@spec parse(Saxy.XML.element() | [Saxy.XML.element()]) :: t()

Parses the contents of a relationships file (a Relationships XML element) into a map mapping {id, type} tuples to NLdoc.Conversion.Reader.Docx.Files.Relationship structs.

read!(filepath)

@spec read!(filepath :: String.t()) :: t()

Reads a Docx relationships (.xml.rels) file at the given path and parses it into a single map as returned by parse/1.

Note that multiple relationships files may reuse ID and type combinations from each other, so be careful of merging the results of reading multiple relationships files.