Podium.OPC.Relationships (Podium v0.3.0)

Copy Markdown View Source

.rels file management for OPC relationship parts.

Manages a collection of relationships (each with an ID, type URI, and target path) and renders them to the XML used in .rels files throughout the package.

Summary

Functions

Adds a relationship and returns {updated_rels, rId}.

Returns {rid, target} for the first relationship of the given type, or nil.

Creates relationships from an existing list, setting next_id appropriately.

Creates a new empty relationships collection.

Parses a .rels XML string into a %Relationships{}.

Generates the .rels XML string.

Types

rel()

@type rel() ::
  {String.t(), String.t(), String.t()}
  | {String.t(), String.t(), String.t(), true}

t()

@type t() :: %Podium.OPC.Relationships{next_id: pos_integer(), rels: [rel()]}

Functions

add(rels, type, target, external \\ false)

@spec add(t(), String.t(), String.t(), boolean()) :: {t(), String.t()}

Adds a relationship and returns {updated_rels, rId}.

find_by_type(rels, type)

@spec find_by_type(t(), String.t()) :: {String.t(), String.t()} | nil

Returns {rid, target} for the first relationship of the given type, or nil.

from_list(rels)

@spec from_list([rel()]) :: t()

Creates relationships from an existing list, setting next_id appropriately.

Only ids of the form rIdN contribute to next_id; any other id is kept but ignored when picking the next one, so foreign ids never cause a collision.

new()

@spec new() :: t()

Creates a new empty relationships collection.

parse(xml)

@spec parse(String.t()) :: t()

Parses a .rels XML string into a %Relationships{}.

Each relationship becomes {id, type, target}, or {id, type, target, true} when TargetMode="External". Attribute order in the source does not matter.

to_xml(rels)

@spec to_xml(t()) :: String.t()

Generates the .rels XML string.