Saxy.XML (Saxy v1.7.0)

View Source

Helper functions for building XML elements.

Summary

Functions

Builds CDATA in simple form.

Builds characters in simple form.

Builds comment in simple form.

Builds element in simple form.

Builds empty element in simple form.

Builds processing instruction in simple form.

Builds reference in simple form.

Types

cdata()

@type cdata() :: {:cdata, String.t()}

characters()

@type characters() :: {:characters, String.t()}

comment()

@type comment() :: {:comment, String.t()}

content()

@type content() :: element() | characters() | cdata() | ref() | comment() | String.t()

dec_ref()

@type dec_ref() :: {:reference, {:decimal, integer()}}

element()

@type element() ::
  {name :: String.t(), attributes :: [{key :: String.t(), value :: String.t()}],
   children :: [content()]}

entity_ref()

@type entity_ref() :: {:reference, {:entity, String.t()}}

hex_ref()

@type hex_ref() :: {:reference, {:hexadecimal, integer()}}

processing_instruction()

@type processing_instruction() ::
  {:processing_instruction, name :: String.t(), instruction :: String.t()}

ref()

@type ref() :: entity_ref() | hex_ref() | dec_ref()

Functions

cdata(text)

@spec cdata(text :: term()) :: cdata()

Builds CDATA in simple form.

The encoder splits text containing ]]> into adjacent CDATA sections, preserving the text when parsed.

characters(text)

@spec characters(text :: term()) :: characters()

Builds characters in simple form.

comment(text)

@spec comment(text :: term()) :: comment()

Builds comment in simple form.

The encoder raises ArgumentError if the text contains -- and appends a space if the text ends in a single hyphen.

element(name, attributes, children)

@spec element(
  name :: term(),
  attributes :: [{key :: term(), value :: term()}],
  children :: term()
) ::
  element()

Builds element in simple form.

empty_element(name, attributes)

@spec empty_element(name :: term(), attributes :: [{key :: term(), value :: term()}]) ::
  element()

Builds empty element in simple form.

processing_instruction(name, instruction)

@spec processing_instruction(name :: String.t(), instruction :: String.t()) ::
  processing_instruction()

Builds processing instruction in simple form.

When encoded, the target must be an XML Name other than xml (in any case), and the instruction must not contain ?>. The encoder raises ArgumentError for invalid processing instructions.

reference(character_type, name)

@spec reference(character_type :: :entity | :hexadecimal | :decimal, value :: term()) ::
  ref()

Builds reference in simple form.