Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert an XML schema (XSD) to Relax NG?

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.

like image 331
maxschlepzig Avatar asked Feb 10 '13 22:02

maxschlepzig


2 Answers

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).

like image 123
C. M. Sperberg-McQueen Avatar answered Oct 12 '22 20:10

C. M. Sperberg-McQueen


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.

like image 42
maxschlepzig Avatar answered Oct 12 '22 20:10

maxschlepzig