Find the newest file named docbookx.dtd on your system (the version is listed in the first few lines). It is probably version 4.4.
Assuming it is, use this declaration in your DocBook documents:
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
The DocBook packages provided by Debian, Ubuntu and Fink (OS X) contain DocBook DTDs (v4.4) that are newer than the corresponding RelaxNG? schemas that ship with NxmlMode (v4.2). Therefore NxmlMode is validating against a slightly older standard than your document production toolchain will use. It is advisable to provide NxmlMode with the correct version.
#!/bin/sh set -ex d=~/.schema u=http://www.oasis-open.org/docbook/rng/4.4/docbook-rng-4.4.zip mkdir -p $d cd $d curl -O $u unzip -o `basename $u` rm -f `basename $u` cat >schemas.xml <<EOF <locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0"> <documentElement localName="section" typeId="DocBook"/> <documentElement localName="chapter" typeId="DocBook"/> <documentElement localName="article" typeId="DocBook"/> <documentElement localName="book" typeId="DocBook"/> <typeId id="DocBook" uri="docbook.rnc"/> </locatingRules> EOF
cat >>~/.emacs <<EOF (eval-after-load 'rng-loc '(add-to-list 'rng-schema-locating-files "$d/schemas.xml")) EOF
Basically, you need to download the files from http://www.oasis-open.org/docbook/rng/, put them somewhere, add a schemas.xml file, and tell nxml about them. You can examine the schemas.xml file that ships with NxmlMode for a more detailed example.
References: XML Catalog
Today (2008-06) the above information seems a little outdated to me. To use Docbook in version 5 with namespace support you can start with a document head like this:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE book [ <!ENTITY % projectentities SYSTEM "entities.xml"> %projectentities; ]> <book xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude" xml:lang="de"> ....
Load the document, put all the required tags missing in the example in it (like title, chapters, book-end-tag etc) and make sure that nXML uses the correct RelaxNG? schema. You can use the
Set Schema submenu from the XML menu. For me this resulted in a schema file that looks like this:
<?xml version="1.0"?> <locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0"> <uri resource="user_doc.xml" uri="docbook5xi.rnc"/> </locatingRules>
Please note that this uses docbook5xi which includes support for namespaces. To translate this to xhtml call
xsltproc like this:
shell> xsltproc --xinclude --output user_doc.html docbook-xsl-ns-1.73.2/xhtml/docbook.xsl user_doc.xml
This uses the downloaded docbook-XSL-stylesheets that have be unpacked in the current working directory.
Is it possible to auto-complete xml:id’s? For example you have a section you want to refer to:
<section xml:id="label1"> <title>This is the section with Label1</title> </section> <!-- ... later then --> <xref linkend="la<CURSOR IS HERE>
And then hitting the magic C-RET would complete on the IDs found in the document (ah, I am missing RefTeX here!)
I am not sure, but I do not think so. There is however some code in nXhtml that does similar things when completing /href=la/<CURSOR IS HERE>. Maybe someone wants to generalize this to attributes like xml:id etc?
Coming from a largish LaTeX-Project (a book of 300-odd pages) and being on very friendly terms with AuCTEX? and it’s friends I currently miss the ability to deal with multi-file documents. The concept of a master document which contains all the declarations has become a habit for me. Is there any way of achieving this with docbook and nXML? I seem to remember that PSGML had some way of dealing with multi-file documents but I never used that. I know that I could create a master-XML which then xincludes all the (e.g.) chapters. But how would Emacs know when I am in such a chapter-file what is the master and then know about the schema and entities and stuff like that? (As a side-note: I don’t like outlines so this is no workaround.)
Maybe you should take this question to the NxmlMode mailing list?