Starting with nxml
2006-11-29 18:46:18 GMT
Platform: Intel Pentium M,
Ubuntu Dapper,
emacs21 21.4a-3ubuntu2,
nxml-mode 20041004-5
trang 20030619-4
I am a _long_ time psgml user that eventually will try the leap into
nxml. The reason is that I need context sensitive editing for an XML
format for which I have an XSD schema (the Maven2 POM format).
So I'm fumbling about trying to get started.
I started by trying to create a schema locator, from the description
here:
http://www.dpawson.co.uk/relaxng/nxml/schemaloc.html#d339e168
`C-h v rng-schema-locating-files RET' gives me:
rng-schema-locating-files's value is
("schemas.xml" "/usr/share/emacs/site-lisp/nxml-mode/schema/schemas.xml")
So I did `C-x C-f schema.xml RET' in the same directory as the pom.xml
file that is to be edited. nxml gave the minibuffer message "Using
vacuous schema". I pasted in the example in the above URL, ie.
<?xml version="1.0"?>
<locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0">
<namespace ns="http://www.w3.org/1999/xhtml" uri="xhtml.rnc"/>
<documentElement localName="book" uri="docbook.rnc"/>
</locatingRules>
Then I deleted the <namespace> and <documentElement> elements, and
tried creating a new element. I tried `C-c C-e' to see if that would
give me the list of available elements (that's the psgml binding for
the same... who reads manuals...?
).
That didn't work, so I did `C-h b' to see if there was an
nxml-insert-element command or something similar. The only commands
with "insert" in them, are:
C-c C-u nxml-insert-named-char
C-c C-x nxml-insert-xml-declaration
Some more browsing on Dave's Q&A seemed to indicate that `C-RET' was
the correct command (nxml-complete). But this command just reports
"Cannot complete in this context".
So is the problem that it can't find the schema? Or is this the wrong
command? Or am I trying an insert in the wrong place? Or does the
insert command have a problem with empty elements?
I don't think it is a missing schema, because the show schema location
command, reports
"Using schema /usr/share/emacs/site-lisp/nxml-mode/schema/locate.rnc"
Perhaps it's the wrong command? It seems to be a command to complete
_something_, but how do I know what to complete at this stage....?
Ah... if I type a `<' and _then_ `C-RET' I get a list of whatever can
be inserted at point, which is (probably) the allowed tags. And to
insert attributes I type a space and then `C-RET' again. To complete
an attribute value I type " followed by a space. `C-RET' again gives
me the possibility to insert a new attribute. And typing / and >
closes the element (there seemed to be no magic here).
This works after a fashion. But I prefer the psgml way of `C-e',
select the element, and then respond to prompts for required
attributes, followed by `C-c +' commands to insert other attributes.
Perhaps I'll get used to this way in time? Or perhaps there is a more
psgml-like mode of operation that I haven't discovered yet? (12 years
takes a lot of unlearning...)
Ok, so on to the schema. I've now created a schema.xml file that
resides in the same directory as the pom.xml file, that looks like
this:
<?xml version="1.0"?>
<locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0">
<namespace ns="http://maven.apache.org/POM/4.0.0" uri="maven.rnc" />
</locatingRules>
This based on a pom.xml header looking like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
Next is to give trang a look. Hm... doesn't look like it supports XSD
schema as an input schema...?
http://www.thaiopensource.com/relaxng/trang.html
Or has things happened since James dropped it?
Doesn't look that way, when looking at the man page of the Ubuntu
(debian?) deb package. It has XSD as an output format, but not as an
input format.
Hm... unless I can convert the maven2 XSD schema to an RNG schema, I
might as well roll back to good old psgml. Is there something else I
can use? Or is there a maven2 POM XML RNG schema around?
Ok. From the bottom of http://www.thaiopensource.com/nxml-mode/
I found rngconv. The procedure to use, was:
- download rngconv.zip from
https://msv.dev.java.net/servlets/ProjectDocumentList?folderID=101
- unzip rngconv.zip. It will create the directory rngconv-20060319/
- go to the rngconv-20060319/ directory, and type the following
commands:
wget http://maven.apache.org/maven-v4_0_0.xsd
java -jar rngconv.jar maven-v4_0_0.xsd >maven.rng
trang maven.rng maven.rnc
- then move maven.rnc to whereever the schemas.xml file resides
(currently the same directory as the top level pom.xml file of the
project I'm working on)
So now I appearently have a working schema.
I get an error message from the xsi:schemaLocation attribute.
Does nxml support namespaces? Does anyone know what magic is needed
to do so?
Does anyone have a best practice for setting up my own RNG schema
location? I won't do it tonight. Now it's time for actually _using_
that schema on the pom.xml file(s)...
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch format to Traditional
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
__,_._,___
RSS Feed