Podium.OPC.ContentTypes (Podium v0.3.0)

Copy Markdown View Source

[Content_Types].xml management for the OPC package.

Tracks default content types (by file extension) and override content types (by part name) and renders them to the XML expected at the package root.

Summary

Functions

Adds a default content type for a file extension.

Adds an override content type for a specific part.

Parses a [Content_Types].xml string into a %ContentTypes{}.

Generates the [Content_Types].xml string.

Types

t()

@type t() :: %Podium.OPC.ContentTypes{
  defaults: %{required(String.t()) => String.t()},
  overrides: %{required(String.t()) => String.t()}
}

Functions

add_default(ct, extension, content_type)

@spec add_default(t(), String.t(), String.t()) :: t()

Adds a default content type for a file extension.

Extensions are downcased so a template declaring Extension="PNG" and a part added as "png" do not produce two conflicting Default entries.

add_override(ct, part_name, content_type)

@spec add_override(t(), String.t(), String.t()) :: t()

Adds an override content type for a specific part.

parse(xml)

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

Parses a [Content_Types].xml string into a %ContentTypes{}.

Attributes are matched individually so their order in the source does not matter. Extension values are downcased because OPC extension matching is case-insensitive.

to_xml(ct)

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

Generates the [Content_Types].xml string.