views:

397

answers:

2

I would like to edit XHTML files using Emacs' nxml-mode which can use rnc schemas for on the fly validation. This is all built in to newer Emacs versions.

However, my XHTML files contain elements from another schema. So <foo:foo> tags are valid, but only within the <xhtml:head> of the document.

Currently, nxml complains because the XHTML schema it is using does not describe the foo tag. How do I create a new schema which describes the foo tag in relation to the existing XHTML schema, and how do I apply that schema automatically using schema locating rules in the schemas.xml file?

ie: I would like to validate a document using two schemas simultaneously: the built-in XHTML rules, and some custom rules which add certain namespaced tags.

A: 

Validator.nu has a preset schema that is modified from the the XHTML schema set originally developed by James Clark and one of the additions is rdf:RDF in head, so the schema might be useful to study.

(I have no experience with nxml-mode schema location issues.)

hsivonen
A: 

Problem 1: I believe that you don't want two schemas here, but rather one schema that "include"s another, combined with the overriding/combination rules described in section 9.2 of the RelaxNG tutorial. I'm wrestling with this myself.

Problem 2: I can give you a better answer to the second problem; nxml-mode looks in one of a number of locations for a "schemas.xml" file that performs pattern-matching to associate files with schemas. For the simplest possible mapping, I have this file in the same dir as the xml file:

<?xml version='1.0'?>
<locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0"&gt;
  <uri resource="auto.xml" uri="lab.rnc"/>
</locatingRules>

This file associates the "auto.xml" file with the "lab.rnc" specification.

John Clements