Sax.Partial (sax v1.0.0) View Source
Supports parsing an XML document partially. This module is useful when
the XML document cannot be turned into a Stream
e.g over sockets.
Example
iex> {:ok, partial} = Sax.Partial.new(StackHandler, [])
iex> {:cont, partial} = Sax.Partial.parse(partial, "<foo>")
iex> {:cont, partial} = Sax.Partial.parse(partial, "</foo>")
iex> Sax.Partial.terminate(partial)
{:ok,
[
end_document: {},
end_element: "foo",
start_element: {"foo", []},
start_document: []
]}
Link to this section Summary
Functions
Builds up a Sax.Partial
, which can be used for later parsing.
Continue parsing next chunk of the document with a partial.
Terminates the XML document parsing.
Link to this section Types
Specs
t()
Link to this section Functions
Specs
new(handler :: module(), initial_state :: term(), options :: Keyword.t()) :: {:ok, partial :: t()} | {:error, exception :: Sax.ParseError.t()}
Builds up a Sax.Partial
, which can be used for later parsing.
Specs
parse(partial :: t(), data :: binary()) :: {:cont, partial :: t()} | {:halt, state :: term()} | {:error, exception :: Sax.ParseError.t()}
Continue parsing next chunk of the document with a partial.
This function can return in 3 ways:
{:cont, partial}
- The parsing process has not been terminated.{:halt, user_state}
- The parsing process has been terminated, usually because of fast return.{:error, exception}
- The parsing process has erred.
Specs
terminate(partial :: t()) :: {:ok, state :: term()} | {:error, exception :: Sax.ParseError.t()}
Terminates the XML document parsing.