Mix.Statifier.Corpus.XmlFormat (Statifier v2.6.0)

Copy Markdown View Source

Re-serializes a transformed W3C .scxml document the way the committed W3C test modules hold it: an XML declaration, four-space indentation, comments and processing instructions dropped, whitespace-only text dropped, and the xmlns:conf declaration the predicator transform leaves behind removed.

This is the corpus emitter's port of the formatter in tools/corpus/scxml_w3/cases.exs, parsed with Saxy (a runtime dependency already) instead of xmerl, which Mix prunes from a project's code path. The output is held to that formatter's by a test comparing every committed W3C case's source with the document its generated module holds.

Summary

Functions

Formats xml, returning the formatted document and the root element's datamodel attribute (nil when absent), or the parser's refusal as a sentence.

Functions

format(xml)

@spec format(xml :: String.t()) ::
  {:ok, {String.t(), String.t() | nil}} | {:error, String.t()}

Formats xml, returning the formatted document and the root element's datamodel attribute (nil when absent), or the parser's refusal as a sentence.

Examples

iex> Mix.Statifier.Corpus.XmlFormat.format(~s|<scxml datamodel="predicator"><!-- c --><state id="a">\n</state></scxml>|)
{:ok, {~s|<?xml version="1.0" encoding="UTF-8"?>\n<scxml datamodel="predicator">\n    <state id="a" />\n</scxml>\n|, "predicator"}}