xmlparser

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseItems

func ParseItems[T any](ctx context.Context, order TokenParseOrder) rxgo.Observable

ParseItems reads annotated item of types T with context.Context. TokenParseOrder will dictate current io.Reader position and io.Closer for resource

Types

type Decoder

type Decoder interface {
	Token() (xml.Token, error)
	DecodeElement(v any, start *xml.StartElement) error
}

Decoder abstracts *xml.Decoder for xml parse

type Parser

type Parser[T any] interface {
	Parse(ctx context.Context, order TokenParseOrder) rxgo.Observable
}

Parser abstracts parser object that parses given io.Reader into data.Transform. Internal parse mechanism is up to how ParseFunc is implemented.

func NewParser

func NewParser[T any]() Parser[T]

type TokenMatcher

type TokenMatcher func(token xml.Token) bool

func NewStartTokenNameMatcher

func NewStartTokenNameMatcher(name string) TokenMatcher

type TokenParseOrder

type TokenParseOrder interface {
	Decoder
	io.Closer
	Match(token xml.Token) bool
}

TokenParseOrder works as input source, decoder and matcher for given source. Match function is the key function to determine target types and value of token.

func SimpleTokenOrder

func SimpleTokenOrder(source io.ReadCloser, localName string) TokenParseOrder

SimpleTokenOrder returns TokenParseOrder implementation that matches specific localName of the token from XML stream.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL