You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Emacs nxml-parent-document-set无法继承父文档实体的问题咨询

关于Emacs nxml-mode中nxml-parent-document-set的实体继承问题

问题核心

我在Emacs的nxml-mode中使用nxml-parent-document-set函数,无法实现预期功能——让章节文件继承父文档中定义的&date;、&version;等内部实体。

我的场景是基于自定义RNC Schema工作,章节文件既要能作为书籍的外部实体被处理,也要能作为独立完整文档使用。但父文档声明的内部实体在章节文件中完全不可见,导致打开章节文件时rnc-validate会标记错误。

函数的文档描述称其能“Set `nxml-parent-document' and inherit the DTD &c.”,但函数内部注释明确写着:

;; FIXME: this does not work.
;; the idea is that by inheriting some variables from the parent,
;; rng-validate-mode' will validate entities declared in the parent. ;; alas, the most interesting variables (rng-compile-table' et al)
;; are circular and cannot be printed even with `print-circle'.

我不确定这段注释是指实体继承功能完全失效(目前实际表现确实如此),还是仅针对rng-compile-table这类变量的打印问题,想确认这是Bug还是我的用法有误。

当前临时处理方式

我发现可以扩展xmltok.el中定义的xmltok-predefined-entity-alist,给实体添加虚拟值来消除验证错误,但这明显是权宜之计。

已查阅的资源

  • Emacs Wiki中“Multi-File Documents”的说明(仅建议咨询已停更的nxml-mode邮件列表)
  • help-gnu-emacs列表中14年前的类似问题,未得到任何回复
  • 当前环境:Emacs 29.1,nxml-mode.el版本为2022年版

备选方案(均不理想)

  • 在章节文件中临时添加<!DOCTYPE声明,处理时再移除
  • 使用@DATE@这类标记通过sed工具替换

求助需求

  1. 明确nxml-parent-document-set无法继承内部实体是功能Bug还是我的用法错误
  2. 寻求更合适的技术求助渠道(nxml-mode邮件列表已停更,help-gnu-emacs又过于通用)

内容的提问来源于stack exchange,提问作者Norman Gray

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 02:23:15