EmacsnXML

WebHome | UnixGeekTools | Geekfarm | About This Site

Pointers

Schemas

nXML only supports RelaxNG compact-syntax schemas (.rnc files), e.g.:

    element date { attribute type { text }?,
    element year { text },
    element month { text },
    element day { text } }

Convert your existing schema to rng format using the sun relaxng converter:

    java -jar rngconv.jar /path/to/schema.xsd > /path/to/output/master-server-list.rng

Convert the rng format to rnc compact syntax using trang:

    java -jar trang-20030619/trang.jar /path/to/schema.rng /path/to/output/schema.rnc

Folding

Built-in nXML folding only works if you are in a valid 'section'. An XML element is treated as a section if:

(setq nxml-section-element-name-regexp "myregexp")
(setq nxml-heading-element-name-regexp "\\(regexp1\\|regexp2\\)")

HideShow - another folding option

I added the code below to enable hideshow in nXML mode:

; hide-show for nxml mode
(add-to-list 'hs-special-modes-alist
             '(nxml-mode
               "<!--\\|<[^/>]>\\|<[^/][^>]*[^/]>"
               ""
               "<!--" ;; won't work on its own; uses syntax table
               (lambda (arg) (my-nxml-forward-element))
               nil))

(defun my-nxml-forward-element ()
  (let ((nxml-sexp-element-flag))
    (setq nxml-sexp-element-flag (not (looking-at "<!--")))
    (unless (looking-at outline-regexp)
      (condition-case nil
          (nxml-forward-balanced-item 1)
        (error nil)))))

Other folding fu





Updated Sat Oct 7, 2006 12:52 PM