开发者

Generate an XSD file from XML using perl

I have several XML documents , and I 开发者_开发技巧wonder I could I create from them an XSD file (using perl if possible..)

Thanks!


Practically speaking, I would say no. If you are willing to make lots (and lots) of assumptions, then you could probably come up with something, but I think that the reliance on so many assumptions would cause the resulting schema to be so far off the mark that you might as well just write it yourself.

For example, you can specify required element order in a schema, so do I assume that the order of your elements in your sample XML is a requirement, or is it just random? Similarly, elements and attributes are frequently optional. How could that be determined from a set of sample files?

Another example: a schema will often limit the possible values to a range, or a set, or other criteria. How could any application discern that from your XML examples? Should the app assume that your sample files provide all possible values for your elements and attributes?

The basic problem is that your are putting the cart before the horse, so to speak. The XML follows the schema, not vice-versa.

That's probably not the answer you wanted to hear, but hopefully it helps you understand the nature of the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜