Documentation
¶
Overview ¶
Package preserve 实现 GB/T 42133—2022 第 6 章的长期保存处理。
该标准把条款分成两类:可机器判定的合规条件由 ofd-validator 按 profile 规则 上报;本质是转换动作的条款由本包执行。本包只产出新的字节流,不修改输入。
转换使用 internal/ofdxml 读取和写出,使用 etree API 对既有 XML 做定点编辑。 重写的 OFD 元素统一使用 ofd: 前缀,并保留扩展命名空间与混合内容; 未发生改动的条目继续逐字节复制。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change struct {
// Entry 是被改动的包内路径。
Entry string
// Clause 是依据条款。
Clause string
// Action 是人类可读的改动说明。
Action string
// Count 是该条款在本次转换中实际改动的节点数。
Count int
}
Change 描述一处改动,供 --dry-run 展示与审计留痕。
type Options ¶
type Options struct {
// DocType 是 OFD profile 取值,空值时按文件声明的 DocType 自动判定。
DocType string
// Limits 限制输入与输出的规模,零值使用默认限制。
Limits replace.Limits
// Validate 在写出前确认转换没有引入新问题。
//
// 语义刻意不是「输出必须零错误」:真实 OFD 常带既有 XSD 偏差,若以零错误
// 为门槛,转换会在多数文件上直接拒绝输出。判据是错误问题码集合不扩大,
// 详见 verifyNoRegression。
Validate bool
// OnWarning 接收非致命提示,例如输入本就不合规、签名摘要已失效。
OnWarning func(string)
// DropUnreferenced 允许真的删除无人引用的条目(GB/T 42133 6.2.1 e))。
//
// 默认关闭,只报告不删除。删除不可逆,而闭包的正确性依赖引用识别:漏识别
// 一种引用形式就会删掉在用文件。开启时若闭包不完整仍会拒绝删除。
DropUnreferenced bool
}
Options 控制转换行为。
type Result ¶
type Result struct {
// DocType 是本次转换实际应用的 profile 取值。
DocType string
// Entry 是按字典序排列的首个实际改动路径,无改动时为空。
Entry string
// Changes 是已做出的改动;Plan 给出的是计划中的改动。
Changes []Change
// Entries 是被修改或删除的包内路径,按字典序去重,无改动时为空。
// Plan 的删除候选另见 Unreferenced,不计为已删除条目。
Entries []string
// BeforeErrors 是转换前的错误数,Validate 为真时有效。
BeforeErrors int
// Unreferenced 是包内无人引用的条目,即 6.2.1 e) 的删除候选。
Unreferenced []string
// UnreferencedDropped 是输出成功后确认删除的条目数;Plan 或 Apply 失败时为 0。
UnreferencedDropped int
// ClosureIncomplete 为真时闭包不可信,删除候选不得据此删除。
ClosureIncomplete bool
// ClosureReason 说明闭包为何不可信。
ClosureReason string
}
Result 是一次转换的结果。
Click to show internal directories.
Click to hide internal directories.