Saxy.Partial (Saxy v1.4.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} = Saxy.Partial.new(StackHandler, [])
iex> {:cont, partial} = Saxy.Partial.parse(partial, "<foo>")
iex> {:cont, partial} = Saxy.Partial.parse(partial, "</foo>")
iex> Saxy.Partial.terminate(partial)
{:ok,
[
end_document: {},
end_element: "foo",
start_element: {"foo", []},
start_document: []
]}
Link to this section Summary
Functions
Builds up a Saxy.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 :: Saxy.ParseError.t()}
Builds up a Saxy.Partial, which can be used for later parsing.
Specs
parse(partial :: t(), data :: binary()) :: {:cont, partial :: t()} | {:halt, state :: term()} | {:halt, state :: term(), rest :: binary()} | {:error, exception :: Saxy.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 parser stopping.{:halt, user_state, rest}- The parsing process has been terminated, usually because of parser halting.{:error, exception}- The parsing process has erred.
Specs
terminate(partial :: t()) :: {:ok, state :: term()} | {:error, exception :: Saxy.ParseError.t()}
Terminates the XML document parsing.