Just to be clear: XSD is the file type (and .xsd is the extension) for documents of W3C XML Schema, a validation framework for XML documents. An XML-Schema file states the grammar of an XML application. Think of it as the .yy file used by YACC/Bison to generate an LALR parser. You use it to test whether a document is legal, but not to generate random documents that conform to the grammar.
I sure hope they gave you some documentation for this XML application beyond the mere series of XSD files. For making a sample XML file you're on our own. Start with whatever the root tag is for this document and through trial and error extend this document and periodically run your validator over it:
Code: Select all
xmllint --schema base_schema.xsd main_doc.xml
(The xmllint binary is almost certainly installed on your system; if it's not, emerge dev-libs/libxml2.)
Since XSD is for validating documents rather then generating them, there's no tool to create an empty template from it. The closest thing I know of to be able to do anything of the sort is the XMLMind editor.
The XMLMind editor
could turn out to be useful be useful to you, but it's probably more likely instead to be a trip down the rabbit hole. Still, you might want to grab the evaluation version of it and get a bit of a feel for the XML-making process it supports. It's a commercial XML editor that lets you add only legal elements to your document so that it always follows the schema. It comes bundled with schemata for applications like DITA and DocBook and lets you set up your own custom schemata using an XML Schema. Once you had it set up, you could generate valid documents for the Amazon XML application. It is nice and easy to use (I tried it out years ago).
The downsides: setting up that configuration with the XML schema is tricky, the editor is a commercial product, and the evaluation version might not let you set up custom configurations. You ought to be aware of this package, though you, like me, may choose not to use it.
Now why validate, you ask? Having the validator can turn out to be quite handy. XML documents that get big might go wrong somewhere and by having things misnamed the application consuming the XML file might misbehave in subtle ways. (This is a reason why using XML files for system configuration is a bad choice.) I have written RelaxNG files for XML applications I've designed; it helps make sure that things are going the right way (RelaxNG is a different validator framework; I prefer it to XML Schema).
You mentioned making your own grammar. Is this really what you are doing, or are you simply creating documents that match what Amazon has given you? Perhaps you're extending the Amazon schema to do what you need. If you're doing ambitious things like that, I would advise making adjustments to that XSD framework.
Just to know, the lingo around XML uses the word
schema to describe what you'd call a
grammar if you were speaking of a programming language. The basic construction of XML is quite fixed: elements, attributes, CDATA, namespaces, entities, and all that. The schema has to do with the rules for assembling these fixed components. You don't get to make up your own markup.
As an example, look at this bit of XHTML:
Code: Select all
<div class="top">
<a href="that_page.html">Go there</a>
</div>
The standard for XHTML requires, among other things, that the <a> element have an
href attribute and/or a
name attribute and may take character data (CDATA) as content, but would not allow, say, a
cellspacing attribute to be present. A schema for XHTML (whether written in XML Schema or RelaxNG) would express all these things and would cause a validator like xmllint enforce them.