Camille B?gnis wrote:
> 
> I am currently working on a project for which I wrote two DocBook5
> customizations (one extension using an additional namespace, and a
> subset). In addition, the users will need to author plain DocBook5
> documents.
> 
> So I use something like this in the addon configuration to detect the
> proper configuration, based on filename extension:
> 
>   <detect>
>     <and>
>       <fileNameExtension>fct</fileNameExtension>
> <rootElementNamespace>http://docbook.org/ns/docbook</rootElementNamespace>
>     </and>
>   </detect>
> 
> I have two questions here:
> 
> 1) As I understand it in the doc, there is no precedence order if
> configuration files are installed in the same directory. In this case,
> how do XXE decides whether to use the customized addon or the plain
> docbook5 addon?

You cannot/should not rely on the internal behavior of XXE (which I
don't remember) to do this. See below.

> 2) I have noticed that the first document I load into XXE determines the
> schema to be used for all subsequent documents having the same
> namespace, ignoring the actual schema defined in the addon loaded. 

The <dtd>, <schema> and <relaxng> configuration elements are just used
to specify which grammar to use when there is no directive in the
document or in the document template being opened.

> While
> I understand the technical rational behind it, it introduces a
> "hysteresis" in the behavior of the application. Is it possible to avoid
> this?

In order to do what you want:

* There is no problem having several configuration files in the same
add-on directory.

* The name of these configurations must *not* be "DocBook" (which will
be reserved to plain DocBook).

* Each configuration file must have a <detect> element selecting
documents which could not be selected by other DocBook-family
configurations.

* Your configurations may reuse configuration elements (not <detect> of
course), commands, macros, etc,  from the stock DocBook configuration
(no namespace) or from the DocBook5 RELAX NG configuration
(http://docbook.org/ns/docbook namespace).

* In principle, commands which are specific to DocBook (promote, demote,
CALS table commands, etc) are namespace-agnostic: they do their work
based on local names.

* DTD, W3C XML Schemas are cached. RELAX NG Schemas are cached too but
with a different, much simpler, behavior.

The cache needs to associate ``grammar names'' with schema objects or files.

- A DTD is identified by its public ID.
- A W3C XML Schema is identified by its target namespace.
- A RELAX NG Schema is identified by its name (see
http://www.xmlmind.com/xmleditor/_distrib/doc/configure/relaxng.html).

Therefore if you want to use the cache, your configurations must be
associated to document types having different ``grammar names''.

Alternatively, you can disable the schema cache. Example:
"xxe -putpref useDocTypeCache false"

In a nutshell, even if all your configurations apply to documents
belonging to the DocBook family, you must treat these documents as if
they were not related to DocBook.

---
PS: The DocBook, Simplified DocBook and DocBook5 configurations prove
that it works fine and may be used as examples of what to do.


Reply via email to