ElixirXML.Namespace (ElixirXML v0.0.1)

View Source

A module for handling XML namespaces, including extracting and reversing XML namespace mappings.

This module provides:

  • extract/2: Parses XML elements and separates namespaces.
  • reverse/2: Reconstructs prefixed XML names from namespace mappings.

Summary

Functions

Extracts namespaces from XML elements and normalizes them.

Reverses namespace extraction, restoring prefixed XML names.

Functions

extract(data, ns_map \\ %{})

@spec extract(binary(), map()) :: binary()
@spec extract(list(), map()) :: list()
@spec extract(map(), map()) :: map()

Extracts namespaces from XML elements and normalizes them.

Examples

iex> ElixirXML.Namespace.extract(%{name: "ns:tag", attributes: [{"xmlns:ns", "http://example.com"}], children: []})
%{name: "tag", ns: "http://example.com", attributes: [], children: []}

reverse(data, ns_map \\ %{})

@spec reverse(any(), map()) :: any()

Reverses namespace extraction, restoring prefixed XML names.

Examples

iex> ElixirXML.Namespace.reverse(%{name: "tag", ns: "http://example.com", attributes: [], children: []})
%{name: "ns:tag", attributes: [{"xmlns:ns", "http://example.com"}], children: []}