8

The Relax NG homepage lists the Sun RELAX NG Converter which apparently is able to convert an XSD file to a relaxng one - but the link is dead and a blog entry about secondary sources seems to be outdated as well.

I am not interested in a web-based converter.

Btw, the XML schema I want to convert uses inheritance.

maxschlepzig
  • 35,645
  • 14
  • 145
  • 182

3 Answers3

5

Kohsuke Kawaguchi's Relax NG converter (aka the Sun Relax NG Converter) is currently available at http://java.net/projects/msv and http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22net.java.dev.msv%22 (thanks to KK for the information).

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65
5

The old Sun RELAX NG Converter is nowadays bundled with the (Sun) 'Multi-Schema Validator' - msv. With that term you can search in your distributions package repository.

For example Fedora (e.g. 17) includes it.

Install on Fedora

# yum install msv-rngconv msv-manual

Usage on Fedora

$ rngconv my.xsd > my.rng

Test the result:

$ xmllint --relaxng my.rng --noout some.xml

Conversion to compact syntax:

$ trang -I rng -O rnc my.rng my.rnc

(trang is also available via the main Fedora package repository)

The other way (perhaps after adding stuff to the compact syntax file):

$ trang -I rnc -O rng my.rnc my.rng

Msv seems to be quite powerful - I tested it with a fairly sized xsd file that uses inheritance, extensive patterns and includes another xsd file.

maxschlepzig
  • 35,645
  • 14
  • 145
  • 182
  • Strangely trang on Debian Jessie does not seem to be able to convert from rng to rnc anymore. – helcim May 14 '15 at 08:28
  • @helcim, perhaps `trang` isn't free enough for Debian anymore :D. Just kidding, my trang examples contained a mixup in the order of input/output format options (`-I`/`-O`) it is now fixed. Perhaps this was the real issue for you? – maxschlepzig May 14 '15 at 09:27
  • I'm getting: Exception in thread "main" java.lang.NoSuchMethodError: com.thaiopensource.relaxng.parse.sax.SAXParseable.(Ljavax/xml/transform/sax/SAXSource;Lcom/thaiopensource/resolver/xml/sax/SAXResolver;Lorg/xml/sax/ErrorHandler;)V at com.thaiopensource.relaxng.input.parse.sax.SAXParseInputFormat.makeParseable(SAXParseInputFormat.java:25) at com.thaiopensource.relaxng.input.parse.ParseInputFormat.load(ParseInputFormat.java:40) at com.thaiopensource.relaxng.translate.Driver.run(Driver.java:135) at com.thaiopensource.relaxng.translate.Driver.main(Driver.java:44) – helcim May 15 '15 at 10:18
0

Have you tried Trang? (I don't know how it deals with inheritance)

See also xsd to rnc (or rng) conversion (unix command line) for a general discussion on converting XSD to RELAXNG. It looks like the Sun RELAX NG Converter goes under the name rngconv, and still hides out in certain places: http://rpm.pbone.net/index.php3?stat=3&search=msv-rngconv&srodzaj=3

Community
  • 1
  • 1
Rintze Zelle
  • 1,654
  • 1
  • 14
  • 30