From e5685e5c7be4a648d94806a9e106b88705b40611 Mon Sep 17 00:00:00 2001 From: xiaoqidun Date: Tue, 13 Oct 2026 00:33:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=94=B5=E5=AD=90=E5=85=AC=E6=96=87):=20?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E6=A0=87=E5=BC=95=E5=91=BD=E5=90=8D=E7=A9=BA?= =?UTF-8?q?=E9=97=B4=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ofdgo_structure.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ofdgo_structure.go b/ofdgo_structure.go index 769668f..1352937 100644 --- a/ofdgo_structure.go +++ b/ofdgo_structure.go @@ -23,6 +23,12 @@ import ( "strings" ) +// 公文标引类型标识 +const structureTypeOfficial = "od" + +// 2013版电子公文标引命名空间 +const structureNamespaceEGov2013 = "http://www.nits.org.cn/eGovDoc/2013" + // Structure 保存自定义标引入口及结构树,单个文件解析失败时通过Error报告,不影响其他标引 type Structure struct { TypeID string `json:"typeId,omitempty"` @@ -188,7 +194,18 @@ func parseStructure(ctx context.Context, data []byte, tag CustomTag) (*Structure // 入参: tag 标引入口, namespace 内容根节点命名空间 // 返回: bool 是否使用公文引用规则 func structureOfficial(tag CustomTag, namespace string) bool { - return tag.TypeID == "od" || namespace == "http://www.nits.org.cn/eGovDoc/2013" && tag.NameSpace == namespace + if tag.TypeID == structureTypeOfficial { + return true + } + if tag.NameSpace != namespace { + return false + } + switch namespace { + case structureNamespaceEGov2013: + return true + default: + return false + } } // structureObjectIDs 按公文标引规则拆分图元标识,保留顺序和重复项