Documentation
¶
Overview ¶
Package xmlenc 有关文档格式编解码处理
Index ¶
- func Decode(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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AttrDecoder ¶
type AttrDecoder interface {
// DecodeXMLAttr 解析属性值
//
// 接口应该只返回 *core.Error 作为错误对象。
DecodeXMLAttr(p *Parser, attr *Attribute) error
}
AttrDecoder 实现从 attr 中解码内容到当前对象的值
type AttrEncoder ¶
type AttrEncoder interface {
// EncodeXMLAttr 仅需要返回属性的 XML 表示,不需要包含属性值的引号字符。
EncodeXMLAttr() (string, error)
}
AttrEncoder 将属性值编码成符合 XML 规范的值
type BaseAttribute ¶
BaseAttribute 所有 XML 属性节点的基本元素
type BaseTag ¶
type BaseTag struct {
Base
StartTag Name `apidoc:"-"` // 表示起始标签名
EndTag Name `apidoc:"-"` // 表示标签的结束名称,如果是自闭合的标签,此值的 Local.Value 为空。
}
BaseTag 所有 XML 标签的基本元素
type Decoder ¶
type Decoder interface {
// DecodeXML 从 p 中读取内容并实例化到当前对象中
//
// 必须要同时从 p 中读取相应的 EndElement 才能返回。
// end 表示 EndElement.End 的值。
//
// NOTE: 如果是自闭合标签,则不会调用该接口。
//
// 接口应该只返回 *core.Error 作为错误对象。
DecodeXML(p *Parser, start *StartElement) (end *EndElement, err error)
}
Decoder 实现从 p 中解码内容到当前对象的值
type Encoder ¶
type Encoder interface {
// EncodeXML 仅需要返回元素内容的 XML 编码,不需要包含本身的标签和属性。
EncodeXML() (string, error)
}
Encoder 将元素内容编码成 XML 内容
type Instruction ¶
Instruction 表示 XML 的指令
type Parser ¶
type Parser struct {
*lexer.Lexer
*core.MessageHandler
}
Parser 代码块的解析器
type Sanitizer ¶
type Sanitizer interface {
// Sanitize 验证数据是否正确
//
// 可以通过 p.Error 等方法输出错误信息
Sanitize(p *Parser)
}
Sanitizer 用于验证和修改对象中的数据
Click to show internal directories.
Click to hide internal directories.