Trang and Relaxer can create RELAX NG schemas on the fly, in either XML or compact syntax.
Trang (http://www.thaiopensource.com/relaxng/trang.html) can translate XML documents into RELAX NG schemas, in either XML or compact syntax. Likewise, Relaxer (http://www.relaxer.org) can produce RELAX NG schemas in XML syntax. This means that you can develop an XML document and then instantly produce a RELAX NG schema for it. The schemas that Trang or Relaxer produce may not be exactly what you want, but they will give you a good start—a schema that you can edit for your own purposes. By the way, Trang can also produce XML Schema documents and DTDs. This hack will walk you through the steps to automatically produce RELAX NG schemas, in either XML or compact formats, from an XML document.
We’ll translate the document newhire.xml. This document is based on specifications from the HR-XML Consortium (http://www.hr-xml.org/channels/home.htm), which develops XML vocabularies for human resource applications. The file newhire.xml contains some personal information about an employee, Floyd Filigree, who lives in New York:
<?xml version="1.0" encoding="UTF-8"?> <Employee xmlns="http://ns.hr-xml.org"> <PersonName> <GivenName>Floyd</GivenName> <FamilyName>Filigree</FamilyName> <Affix type="formOfAddress">Mr</Affix> </PersonName> <PostalAddress> <CountryCode>US</CountryCode> <PostalCode>10001</PostalCode> <Region>NY</Region> <Municipality>New York</Municipality> ...