This is the mail archive of the mailing list for the DocBook project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [docbook] Listing a kickstart XML file within Docbook

Kerry Cox <kerryjcox 'at'> writes:

> I am attempting to explain to beginning users here at my job how to
> create a kickstart file for use with Red Hat servers. As we use
> Opsware provisioning software, this kickstart XML file has gotten
> rather bulky and I am getting all sorts of errors as I attempt to
> render it under Docbook.
> I have tried <programlisting> and the <![CDATA[  ]]> tags. Regular
> comments do not prohibit the xml tags and Bash scripts within the
> sample XML from causing havoc with Docbook.
> I have also tried <computeroutput> and no success.
> Any suggestions for rendering XML files within Docbook?

If you can filter the source XML files before building the
docbook source file, you may want to "xml escape" them, e.g.
substitute XML special chars with their entity counterparts.

The following is an example of such a function in emacs-lisp. If
you need something automated this is probably not the best way,
though :)

(defvar xml-escape-translate-map
    ("&"  . "&amp;") ; keep this one in first position
    ("<"  . "&lt;")
    (">"  . "&gt;")
    ("'"  . "&apos;")
    ("\"" . "&quot;")

(defvar xml-escape-search-for
  (mapconcat (lambda (entry) (car entry)) xml-escape-translate-map "\\|"))

(defun xml-escape ()
  "escape XML special characters"
  (if (mark)
      (let ((save-point (point-marker)))
        (if (> (point) (mark)) (exchange-point-and-mark))
        (while (re-search-forward xml-escape-search-for (mark) t)
           (cdr (assoc (match-string 0) xml-escape-translate-map)) t t))
        (goto-char save-point)

Guillaume Cottenceau

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]