help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

nxml-mode and parent documents


From: Norman Gray
Subject: nxml-mode and parent documents
Date: Tue, 09 Jan 2024 14:58:00 +0000

Greetings.

[The answer to this might be: 'ask over there...-->' ! ]

I'm using the nxml-parent-document-set function in Emacs nxml-mode. It doesn't 
do what I expect (namely pull in internal entities such as &date; or &version; 
which are defined in the parent document), and I'm not sure whether I should be 
expecting that, or if there's a better way to achieve what I want.

I'm working with a custom (RNC) schema, in which the files containing 
‘chapters’, can be processed either as part of a ‘book’ (ie, included as 
external entities), or standalone (where they are the complete document). The 
problem is that internal entities declared in the ‘book’ file are not visible 
in the ‘chapter’ file, so rnc-validate flags them as an error when visiting 
that file.

It appears that nxml-parent-document-set should resolve this, since it's 
documented as

> Set `nxml-parent-document' and inherit the DTD &c.

However the comment attached to the function is

> ;; 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'.

I'm not sure whether the ‘alas’ there is telling me this doesn't in fact work 
(and it appears not to), or whether this is a side-remark about printing other 
‘interesting variables’.

That is: is this a bug, or am I using this incorrectly?

I see that I can make the validation errors go away by extending the definition 
of xmltok-predefined-entity-alist (defined in xmltok.el) to include dummy 
values for the entities I want to refer to, but... that seems like a bit of a 
hack!

For reference, I see

...an emacs wiki note [1] about ‘Multi-File Documents’ which suggests asking on 
the (now apparently defunct) nxml-mode mailing list.
...a 14-year old query on the help-gnu-emacs list [2] which seems to have gone 
unanswered.

I'm using Emacs 29.1, and a version of nxml-mode.el which is dated 2022.

An alternative strategy is to include the <!DOCTYPE declarations in the 
‘chapter’ files, but somehow strip those out with some sort of cunning 
manoeuvre during processing (unappealing). Another alternative is to include 
the relevant information as, eg, @DATE@, and sed-substitute those in with a 
different manoeuvre (unappealing for different reasons).

Best wishes,

Norman



[1] [emacs wiki 
note](https://www.emacswiki.org/emacs/UsingNxmlModeWithDocBook#toc6)
[2] [14-year old query on the help-gnu-emacs 
list](https://lists.gnu.org/archive/html/help-gnu-emacs/2009-10/msg00471.html)


-- 
Norman Gray  :  https://nxg.me.uk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]