I need to create a XSD schema based on a XML file. Are there any Perl modules which can do this?
You can create the XSD by a XSL transformation using any XSLT processor. See XML::XSLT
An XSD file contains two element types: simple and complex. All leaf nodes have to be translated into simple type elements and the others have to be translated into complex types. Leaf nodes are nodes without any descendants. The corresponding XPath is //*[not(descendant::element())]
. The following XSLT implements this approch:
The following example:
Peter
Pan
1904
12
27
Will produce the following schema: