There is a bug in reporting errors for rng validation.
I've attached an example xml file which is in it's current form valid (and proclaimed so by xml copy editor).
If you make it invalid (for example remove on of the attributes of a splnode tag), it reports
Error at line 6: Element subovl has extra content: subovl
This error is completely bogus.
The rng files you need can be found in the svn of my project:
http://rct3.svn.sourceforge.net/viewvc/rct3/trunk/RCT3%20Importer/doc/xml/
You need the following files:
rct3xml-raw-v1.rng
rct3xml-shared-v1.rng
rct3xml-installer-shared-v1.rng
The first is the one to be validated against (the others are included form it).
Example xml
Logged In: NO
Thanks Tobias, I need to look into this.
Cryptic error reporting is a known issue of rng - some people use trang to convert rng to xsd before validating - and I'm hoping to alleviate the situation by printing more than one error for all validation (though that may backfire for rng, which may list every single element in the document).
I agree, though, that taking something away should never change the message from "is valid" to such-and-such an element has "extra content" :-|
I should say that I'm not touching the error messages in any way. libml parses and validates the instance and the error is the one reported by libxml's rng validator.
-gerald
Logged In: YES
user_id=573198
Originator: YES
Damn, you're right. xmllint gives the same error :-/
Time to complain upstream.
Logged In: YES
user_id=573198
Originator: YES
Ok, I think this is either a regression or an uncaught variant of this here:
http://bugzilla.gnome.org/show_bug.cgi?id=324164
Logged In: NO
Thanks for letting me know Tobias! Should have checked that earlier but would've been surprised had xmllint responded differently.
Thanks also for submitting the upstream bug report.
-Gerald
Logged In: YES
user_id=573198
Originator: YES
Unfortunately after taking a look-around in libxmls bugzilla, I won't hold my breath for an upstream fix :/
There's a pletora of RelaxNG bugs similar to this one and they haven't been fixed in years.
Depending on which compiler you use it might actually be worth looking into trying gcj and using jing...
Logged In: NO
Oh dear that's bad news: thanks for the update. As the only mainstream C/C++ implementation of rng (or did I overlook one?) libxml really needs to get this right.
XML Schema has Xerces-C and MSXML (and also a well-understood association mechanism - I'm familiar with the reasons against instance association in rng, but the fact is LOADS of XML Schema users associate their schemas to the instance though nobody forces them to).
-Gerald
Logged In: YES
user_id=573198
Originator: YES
I found this one:
http://www.davidashen.net/rnv.html
rnc only, but seems to work for my files. The drawback is that the code is hardcore ansi C (the kind where there's hardly any variable name longer than two characters...), API documentation is non-existant. I might experiment with it a bit, so maybe I can help with it later.
Logged In: NO
nothing wrong with ansi c! no book like The C Programming Language. shredded the binding of mine reading and rereading it :-)
-gerald
Logged In: YES
user_id=573198
Originator: YES
Bad wording :p
Should have said "the kind of hardcore ansi C where hardly any ..."
On a different note I found some xslt sheets to convert rng to rnc (http://www.pantor.com/download.html) and I'll probably try to create a proper RelaxNG validator for the project I'm working on using rnv. If it works, I'll let you know.
Logged In: YES
user_id=573198
Originator: YES
RNV moved here =)
http://sourceforge.net/projects/rnv
Logged In: YES
user_id=573198
Originator: YES
After a frustrating bug hunt I now got it to work and it seems to do so fabulous.
I've not looked at every detail, but this might even be ideal for you. When parsing, it seems to be possible to query information about every node, so you can practially besides validation determine what each element expects to see or tolerates. With validation you basically seem to get free autocomplete!
The drawback is that it relies on globals big time, so it can only use one schema at a time. As it seems to lex RNCs reasonably fast, I don't think that's a problem, but to be sure I will do a bit of timing later.
Logged In: YES
user_id=573198
Originator: YES
Oh, I forgot: In comparison to jing it also bails out earlier. Jing continues validation inside invalid elements, rnv does not. Alas I wouldn't want to decide whose behavior is wrong =)
Logged In: YES
user_id=1298822
Originator: NO
Thanks Tobias, I really like the sound of this. As I think I've said in an earlier post I'm revamping the whole autocompletion mechanism (probably with a separate thread for validation the output of which is polled at idle time).
I'm just glad rnc is seeing some attention in a library I can link to. (V. frustrating to see .NET and Java pulling ahead in terms of library support.)
Really squeezed for development time unfortunately. Need to gain some momentum so I can launch the 1.1.1 series.
What's the XML project you're working on, or is this part of your work on rollercoaster tycoon?
-Gerald
Logged In: YES
user_id=573198
Originator: YES
It's currently part of the RCT3 project, but I'm writing it as a library, so it can be reused. It started as a light c++ wrapper around libxml2 and libxslt, but as I saw the shortcomings of that, I started to add "enhanced features". It's basically in early stages and implement-what-I-need-as-soon-as-I-need-it (and not yet in svn).
But I have some goodies already implemented, namely the rnv based rnc validation (plannig to add rng by transformation via xslt) and a (xslt based) iso schematron validator. I also have "stock" libxml2 based RelaxNG and Schematron validators, but as you can guess they stem from the time where I though they were actualy usable =)
If you want to use rnv, I suggest waiting till I have my modifications in svn. Not so much for the libxml2 callback based rnc loading, but more for a couple of cleanup errors I fixed. Still it leaks memory (I belive), but at least the leak seems to be constant and not increase with repeated reuse =)
I've also started with the performance tests and it looks very promising. I converted the docbook rng to rnc via xsltproc, putting everything in one rnc file. This rnc file is around 135kb big and rnv parses it from memory in about 0.031 seconds. I'm working on timing the xslt transforms I need to do for direct rng support, but I guess they are around 100x slower.
Logged In: YES
user_id=573198
Originator: YES
I've now committed to svn what I've got so far.
Preformance tests showed what I suspected (for the docbook rng):
incelim xsl: 4.8s
RngToRnc xsl: 99.0s (!)
Parsing (rnv): 0.031s
So basically rnv parses rnc immediately for all practical applications =)