Documentation
¶
Overview ¶
Package token 解析 xml 内容
Index ¶
- func Decode(h *core.MessageHandler, p *Parser, v interface{}, namespace string)
- func Encode(indent string, v interface{}, namespace, prefix string) ([]byte, error)
- type AttrDecoder
- type AttrEncoder
- type Attribute
- type Base
- type BaseAttribute
- type BaseTag
- type CData
- type Comment
- type Decoder
- type Encoder
- type EndElement
- type Instruction
- type Name
- type Parser
- type Sanitizer
- type StartElement
- type String
- type Tip
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AttrDecoder ¶
type AttrDecoder interface {
// 解析属性值
//
// 接口应该只返回 *core.SyntaxError 作为错误对象。
DecodeXMLAttr(p *Parser, attr *Attribute) error
}
AttrDecoder 实现从 attr 中解码内容到当前对象的值
type AttrEncoder ¶
AttrEncoder 将属性值编码成符合 XML 规范的值
type BaseAttribute ¶
BaseAttribute 所有 XML 属性节点的基本元素
type BaseTag ¶
type BaseTag struct {
Base
StartTag Name `apidoc:"-"` // 表示起始标签名
EndTag Name `apidoc:"-"` // 表示标签的结束名称,如果是自闭合的标签,此值为空。
}
BaseTag 所有 XML 标签的基本元素
type Decoder ¶
type Decoder interface {
// 从 p 中读取内容并实例化到当前对象中
//
// 必须要同时从 p 中读取相应的 EndElement 才能返回。
// end 表示 EndElement.End 的值。
//
// NOTE: 如果是自闭合标签,则不会调用该接口。
//
// 接口应该只返回 *core.SyntaxError 作为错误对象。
DecodeXML(p *Parser, start *StartElement) (end *EndElement, err error)
}
Decoder 实现从 p 中解码内容到当前对象的值
type Instruction ¶
Instruction 表示 XML 的指令
type Parser ¶
Parser 代码块的解析器
func (*Parser) NewError ¶
func (p *Parser) NewError(start, end core.Position, field string, key message.Reference, v ...interface{}) error
NewError 生成 *core.SyntaxError 对象
type Sanitizer ¶
type Sanitizer interface {
// 验证数据是否正确
//
// 可以通过 p.NewError 和 p.WithError 返回 *core.SyntaxError 类型的错误
Sanitize(p *Parser) error
}
Sanitizer 用于验证和修改对象中的数据
type StartElement ¶
StartElement 表示 XML 的元素
Click to show internal directories.
Click to hide internal directories.