View Source Exogiri.Xml.Schema (exogiri v0.2.0)

Encapsulates an XML schema.

Link to this section Summary

Types

t()

The Schema type.

Functions

Read a schema from a string.

Read a schema from a string with a path.

Validate a document against a schema.

Link to this section Types

Specs

t()

The Schema type.

Link to this section Functions

Specs

from_string(String.t()) :: {:error, :unknown_error | [String.t()]} | {:ok, t()}

Read a schema from a string.

As you don't have a path, this doesn't handle more complex cases like included or imported schemas, if either is local.

Link to this function

from_string(string, path)

View Source

Specs

from_string(String.t(), String.t()) ::
  {:error, :unknown_error | [String.t()]} | {:ok, t()}

Read a schema from a string with a path.

This version handles local includes and imports correctly. The path argument is the location of the actual schema you are parsing as a string, NOT its directory. The schema isn't read from the path, so it doesn't have to be real - the path is used to establish the base location for any local schema references.

Link to this function

validate_document(schema, doc)

View Source

Specs

validate_document(t(), Exogiri.Xml.Document.t()) ::
  {:error, :validation_context_creation_failure | [String.t()]} | :ok

Validate a document against a schema.