Smee.Transform (Smee v0.6.0)

Copy Markdown View Source

Tools for manipulating metadata XML.

This module is intended to make common and relatively simple actions on potentially large XML files more efficiently than processing a metadata or entities using xmerl, and may rely on external tools such as xsltproc.

These functions are useful for pre-processing metadata XML before it's broken up into entity struct, and to speed-up the internal workings of other modules.

Summary

Functions

Strips various extraneous parts from the metadata and returns a new struct in an :ok/:error tuple

Strips various extraneous parts from the metadata and returns a new struct in an :ok/:error tuple

Applies an XSLT stylesheet to a metadata struct, returning a transformed metadata struct in an :ok/error tuple

Returns a metadata struct with the validUntil date updated, in an :ok/:error struct

Returns a metadata struct with the validUntil date updated, or raises if an error occurs

Functions

decruft_idp(metadata)

@spec decruft_idp(metadata :: Smee.Metadata.t()) ::
  {:ok, Smee.Metadata.t()} | {:error, binary()}

Strips various extraneous parts from the metadata and returns a new struct in an :ok/:error tuple

decruft_sp(metadata)

@spec decruft_sp(metadata :: Smee.Metadata.t()) ::
  {:ok, Smee.Metadata.t()} | {:error, binary()}

Strips various extraneous parts from the metadata and returns a new struct in an :ok/:error tuple

transform(metadata, stylesheet, params \\ [])

@spec transform(
  metadata :: Smee.Metadata.t(),
  stylesheet :: binary(),
  params :: keyword()
) ::
  {:ok, Smee.Metadata.t()} | {:error, binary()}

Applies an XSLT stylesheet to a metadata struct, returning a transformed metadata struct in an :ok/error tuple

valid_until(metadata, date)

@spec valid_until(metadata :: Smee.Metadata.t(), date :: DateTime.t()) ::
  {:ok, Smee.Metadata.t()} | {:error, binary()}

Returns a metadata struct with the validUntil date updated, in an :ok/:error struct

valid_until!(metadata, date)

@spec valid_until!(metadata :: Smee.Metadata.t(), date :: DateTime.t()) ::
  Smee.Metadata.t()

Returns a metadata struct with the validUntil date updated, or raises if an error occurs