File: options.go

package info (click to toggle)
golang-github-antchfx-xmlquery 1.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 196 kB
  • sloc: makefile: 2
file content (33 lines) | stat: -rw-r--r-- 811 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package xmlquery

import (
	"encoding/xml"
	"io"
)

type ParserOptions struct {
	Decoder *DecoderOptions
}

func (options ParserOptions) apply(parser *parser) {
	if options.Decoder != nil {
		(*options.Decoder).apply(parser.decoder)
	}
}

// DecoderOptions implement the very same options than the standard
// encoding/xml package. Please refer to this documentation:
// https://golang.org/pkg/encoding/xml/#Decoder
type DecoderOptions struct {
	Strict        bool
	AutoClose     []string
	Entity        map[string]string
	CharsetReader func(charset string, input io.Reader) (io.Reader, error)
}

func (options DecoderOptions) apply(decoder *xml.Decoder) {
	decoder.Strict = options.Strict
	decoder.AutoClose = options.AutoClose
	decoder.Entity = options.Entity
	decoder.CharsetReader = options.CharsetReader
}