xml

package
v0.1.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "xml"

Name is type name.

Variables

This section is empty.

Functions

func Register

func Register(name string)

Register register marshaler/unmarshaler.

func WithDecoderOption

func WithDecoderOption(unmarshaler encoding.Unmarshaler, opt ...DecoderOption) encoding.Unmarshaler

WithDecoderOption returns a proxy of encoding.Unmarshaler. It wraps DecoderOption into context.Context, and then calls Unmarshal method of the underlying encoding.Unmarshaler with the new context.Context.

func WithEncoderOption

func WithEncoderOption(marshaler encoding.Marshaler, opt ...EncoderOption) encoding.Marshaler

WithEncoderOption returns a proxy of encoding.Marshaler. It wraps EncoderOption into context.Context, and then calls Marshal method of the underlying encoding.Marshaler with the new context.Context.

Types

type CharsetReader

type CharsetReader func(charset string, input io.Reader) (io.Reader, error)

CharsetReader is function for xml.Decoder.CharsetReader.

func AsUtf8CharsetReader

func AsUtf8CharsetReader() CharsetReader

AsUtf8CharsetReader returns a CharsetReader which treat the input content as UTF-8 encoded, no matter what charset the input claims.

func IanaTransformCharsetReader

func IanaTransformCharsetReader() CharsetReader

IanaTransformCharsetReader return a CharsetReader which treat the input content as encoded as what charset it claims. The CharsetReader will look up supported encoding according to the charset name. If no charset found or the encoding is not supported by runtime platform, The CharsetReader returns a non-nil error. The CharsetReader decode the input content by the encoding found.

type DecoderOption

type DecoderOption func(decoder *xml.Decoder)

DecoderOption is a function which modifies a *xml.Decoder.

func WithCharsetReader

func WithCharsetReader(reader CharsetReader) DecoderOption

WithCharsetReader returns a DecoderOption which modifies decoder's CharsetReader.

type EncoderOption

type EncoderOption func(encoder *xml.Encoder)

EncoderOption is a function which modifies a *xml.Encoder

func WithEncodingProcInst

func WithEncodingProcInst(name string) EncoderOption

WithEncodingProcInst returns a EncoderOption which writes a processing instruction. The content of processing instruction will be `<?xml version="1.0" encoding="#{charset-name}"?>`. NOTE: You should provide this option at most once. Only the first option this function produced will work.

func WithIndent

func WithIndent(prefix string, indent string) EncoderOption

WithIndent returns a EncoderOption which modifies the indent the encoder outputs.

Jump to

Keyboard shortcuts

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