9

I read about Relaxer, the thing that compiles .RNG to Java classes. BBut the website, http://www.relaxer.org/, is dead.

Q1:
Is Relaxer alive? Is it real, does it work? Is it reasonable to generate Java classes from .RNG?

Q2:
Is there a Relaxer for .NET? Is there a tool that generates C# classes from RelaxNG schema?

Q3: Is there a Relaxer for Javascript?

AND, finally

Q4:
Is RelaxNG alive? Is it viable? Relevant and useful in the REST/JSON world? Are people still using it or is it going to fade, a good idea that has been dropped? I know that is subjective, but I'd like to know your assessment. I see only 9 or 10 RelaxNG Q's on stackoverflow, so I question the relevance of this technology. If not RelaxNG, then what? WADL? Nothing?


See Maintaining Consistency Between JavaScript and C# Object Models for a related question.

Community
  • 1
  • 1
Cheeso
  • 189,189
  • 101
  • 473
  • 713

2 Answers2

10

Just use Mono's RelaxngValidatingReader.

I've made a NuGet Package by compiling the Mono Commons.Xml.Relaxng project.

PS: I use this in production for some AlpineBits projects.

XmlReader instance = new XmlTextReader ("instance.xml");
XmlReader grammar = new XmlTextReader ("grammar.rng");
using (RelaxngValidatingReader reader = new RelaxngValidatingReader (instance, grammar)) {
    try {
        while (!reader.EOF) {
            reader.Read();
        }
        Console.WriteLine("validation succeeded");
    }
    catch (Exception ex) {
        Console.WriteLine("validation failed with message:");
        Console.WriteLine(ex.Message);
    }
}
Martin Meixger
  • 2,547
  • 24
  • 26
  • Any documentation for the project? Like how to use it? In `Documentation/en` I see some XML documentation, but is there a rendered (HTML) version? – Franklin Yu Sep 15 '17 at 14:21
  • @FranklinYu Added a simple example how to validate a xml file. Also see the [unit tests](https://github.com/mono/mono/blob/master/mcs/class/Commons.Xml.Relaxng/Test/RelaxngValidatingReaderTests.cs) in the mono repository. – Martin Meixger Sep 16 '17 at 15:41
  • Thank you. I thought there is some documentation of `Commons.Xml.Relaxng` online available, since there is [one for most parts of Mono](http://docs.go-mono.com/). I still think that some documentation would improve, and may try adding that into the mono repository via pull request. (Or maybe ask about it in [mailing list](https://lists.dot.net/mailman/listinfo/mono-docs-list).) – Franklin Yu Sep 17 '17 at 07:11
4

Rather than let this question hang out here unanswered forever, and going on the theory that no answer at all is actually a pretty definitive answer, I'm going to provide a response myself.

The answers:

  1. No, by all indications, Relaxer is not alive.

  2. There is no Relaxer for .NET

  3. There is no Relaxer for Javascript

  4. RelaxNG is apparently also dead still alive, just looking deadish as it is stable, but it is used quite a lot as alternative to XSD. A recent addition was RelaxNG validation in Saxon for XQuery and XSLT done by Charles Foster.

  5. There are a bunch of alternatives for RelaxNG validation in .NET, as mentioned in the comments and Martin's answer.

Abel
  • 56,041
  • 24
  • 146
  • 247
Cheeso
  • 189,189
  • 101
  • 473
  • 713
  • 1
    I've successfully been using Tenuto as a RelaxNG validator for .NET. It is listed here: http://www.relaxng.org/ – Dirk Vollmar Jul 16 '10 at 09:18
  • 1
    For what it's worth, Trang seems to do a lot of what Relaxer did, and is actively maintained: http://code.google.com/p/jing-trang/ – Tao Aug 09 '11 at 06:55
  • 1
    I have a specificiation for a Message Schema written in RelaxNG Compact format which I have to convert to an XSD. Yes people care. ftp://medical.nema.org/medical/dicom/final/sup95_ft.pdf – bleepzter Dec 07 '11 at 18:39
  • 1
    I do use Relax-NG, and I'd like to find a living .NET validator for it. – reinierpost Apr 24 '12 at 15:14
  • 6
    By the way, Relax-NG itself seems to be just fine as it is, so there is little need for maintenance. – reinierpost Apr 24 '12 at 15:23