Loading ...
Sorry, an error occurred while loading the content.

Docbook customization

Expand Messages
  • Stephane Bortzmeyer
    I m a recent user of nxml-mode and a less recent user of Docbook customization. I do things like:
    Message 1 of 4 , Apr 27, 2005
    • 0 Attachment
      I'm a recent user of nxml-mode and a less recent user of Docbook
      customization. I do things like:

      <!ELEMENT rfc EMPTY>
      <!ATTLIST rfc num CDATA #IMPLIED>

      <!ENTITY % local.para.char.mix
      "|rfc">

      or like:

      <!-- New attributes -->
      <!ENTITY % local.common.attrib
      "osversionequal CDATA #IMPLIED
      osversionmin CDATA #IMPLIED
      osversionmax CDATA #IMPLIED">

      psgml read them and process them fine. How to do with nxml? Can I
      customize the RelaxNG schema? Or should I go on with the DTD and use
      trang to translate to a RelaxNG file?
    • Vincent Lefevre
      ... Yes, this is what I do. For instance, to add an attribute: local. .attrib |= attribute { ... } -- Vincent Lefèvre
      Message 2 of 4 , Apr 27, 2005
      • 0 Attachment
        On 2005-04-27 12:02:32 +0200, Stephane Bortzmeyer wrote:
        > Can I customize the RelaxNG schema?

        Yes, this is what I do. For instance, to add an attribute:

        local.<elementname>.attrib |= attribute <attributename> { ... }

        --
        Vincent Lefèvre <vincent@...> - Web: <http://www.vinc17.org/>
        100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
        Work: CR INRIA - computer arithmetic / SPACES project at LORIA
      • Bruce D'Arcus
        ... Yes, you can customize a RNG schema; big time! Particularly if it s designed to be customized. Here s my own example: # customization for scholarly
        Message 3 of 4 , Apr 27, 2005
        • 0 Attachment
          On Apr 27, 2005, at 6:02 AM, Stephane Bortzmeyer wrote:

          > Can I customize the RelaxNG schema? Or should I go on with the DTD and
          > use
          > trang to translate to a RelaxNG file?

          Yes, you can customize a RNG schema; big time! Particularly if it's
          designed to be customized.

          Here's my own example:

          # customization for scholarly writing
          namespace db = “http://docbook.org/docbook-ng%e2%80%9d
          namespace mods = “http://www.loc.gov/mods/v3%e2%80%b3
          default namespace = “http://docbook.org/docbook-ng%e2%80%9d

          include “mods-3-0.rnc”
          {
          extensionSchema = db._any
          }

          include “docbook-ng.rnc” {
          db.any = element * - (db:*|mods:*) { db.any.attribute, (text, db._any) }

          # remove all the main software/technology related definitions
          db.domain.inlines = notAllowed
          db.product.inlines = notAllowed
          db.technical.blocks = notAllowed
          db.verbatim.blocks = notAllowed
          db.synopsis.blocks = notAllowed
          # add a new element to quote
          db.quote = element quote { db.quote.attlist, (db.all.inlines |
          hb.nonquote)* }
          # add mods to bibliography element (DocBook's bib model isn't good
          enough)
          db.bibliography = element bibliography {
          db.bibliography.attlist,
          db.bibliography.info,
          db.all.blocks*,
          (db.bibliodiv+ | (ModsSchema | db.biblioentry |
          db.bibliomixed)+)
          }
          }

          # nonquote pattern allows for semantic rendering of split quotes
          like: # “The world,” the guy said, “is flat.”
          hb.nonquote = element nq { empty }


          Bruce
        • Stephane Bortzmeyer
          On Wed, Apr 27, 2005 at 12:27:26PM +0200, Vincent Lefevre wrote ... OK, many thanks, it works for me. And I prefer to edit RNC than DTD,
          Message 4 of 4 , Apr 27, 2005
          • 0 Attachment
            On Wed, Apr 27, 2005 at 12:27:26PM +0200,
            Vincent Lefevre <vincent@...> wrote
            a message of 28 lines which said:

            > Yes, this is what I do. For instance, to add an attribute:

            OK, many thanks, it works for me. And I prefer to edit RNC than DTD,
            anyway. For the record and the archives, here is the complete
            solution. I do not master locatingRules yet, so sorry for the absolute
            path:

            Local schema:

            % cat afnic-docbook.rnc
            include "/usr/share/emacs/site-lisp/nxml-mode/schema/docbook.rnc"

            local.common.attrib |= attribute osversionequal { text }

            rfc = element rfc { attlist.rfc, empty }
            attlist.rfc &= attribute num { text }?

            local.para.char.mix |= rfc


            Docbook conforming document, made with nxml:

            % cat mydoc.db
            <?xml version="1.0" encoding="utf-8"?>
            <article>
            <para osversionequal="1">Very short <rfc num="1"/></para>
            </article>


            Makefile to process, produce the RNG (required by libxml2's xmllint),
            validate:

            % cat Makefile
            all: test

            %.rng: %.rnc
            trang -I rnc -O rng $< $@

            test: afnic-docbook.rng mydoc.db
            xmllint --relaxng afnic-docbook.rng --noout ./mydoc.db
          Your message has been successfully submitted and would be delivered to recipients shortly.