resxml

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package resxml contains common functions to extract information from xml files and feed that information into the resource processing pipeline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attrs

func Attrs(xe XMLEvent) []xml.Attr

Attrs returns all []xml.Attrs encounted on an XMLEvent.

func ForwardChildren

func ForwardChildren(ctx context.Context, start XMLEvent, xmlC <-chan XMLEvent) <-chan XMLEvent

ForwardChildren takes the provided StartElement and a channel of XMLEvents and forwards that all events onto the returned XMLEvent channel until the matching EndElement to start is encountered.

func SendXML

func SendXML(ctx context.Context, xmlC chan<- XMLEvent, xml XMLEvent) bool

SendXML sends an XMLEvent to the provided channel and returns true, otherwise if the context is done, it returns false.

func SloppyMatches

func SloppyMatches(n1, n2 xml.Name) bool

SloppyMatches ignores xml.Name Space attributes unless both names specify Space. Otherwise only the Local attribute is used for matching.

func StreamDoc

func StreamDoc(ctx context.Context, doc io.Reader) (<-chan XMLEvent, <-chan error)

StreamDoc parses the provided doc and forwards all xml tokens to the returned XMLEvent chan.

func StrictMatches

func StrictMatches(n1, n2 xml.Name) bool

StrictMatches considers xml.Names equal if both their space and name matches.

Types

type XMLEvent

type XMLEvent struct {
	Token  xml.Token
	Offset int64
}

XMLEvent wraps an XMLToken and the Offset at which it was encountered.

func ConsumeUntil

func ConsumeUntil(name xml.Name, xmlC <-chan XMLEvent) (XMLEvent, bool)

ConsumeUntil takes xmlEvents from the provided chan and discards them until it finds a StartEvent which matches the provided name. If the channel is exhausted, false is returned.

Jump to

Keyboard shortcuts

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