FeedReader.XML.NamespaceScope (FeedReader v0.4.1)

Copy Markdown

Tracks XML namespace bindings as elements open and close.

Prefixes are aliases, so names must ultimately be matched by namespace URI rather than by a particular spelling such as media or m. Prefix bindings can change in nested elements and revert when those elements close; this helper provides the scope tracking needed for namespace-aware SAX matching.

Enter an element with its attributes to apply any xmlns declarations, then leave it to restore the parent scope. uri/2 returns the URI bound to a prefix, using the empty prefix for the default namespace; unbound or undeclared prefixes return nil.

Summary

Types

t()

@type t() :: %FeedReader.XML.NamespaceScope{scopes: [map()]}

Functions

bound?(namespace_scope, prefix)

@spec bound?(t(), String.t()) :: boolean()

enter(scope, attributes)

@spec enter(t(), [{String.t(), String.t()}]) :: t()

leave(scope)

@spec leave(t()) :: t()

new()

@spec new() :: t()

uri(namespace_scope, prefix)

@spec uri(t(), String.t()) :: String.t() | nil