Jenda has asked for the wisdom of the Perl Monks concerning the following question:

${[scalar localtime()]} monks,
does anyone know of a tool/module that'd either convert a (huge of course) W3C XML Schema to DTD (getting rid of information I'm not interested in anyway) or parse the schema and gave me a reasonably complex datastructure? I'm only interested in things like "this is the root tag(s)", "this tag has these attributes (and possibly ... those are the static ones and have those values)" and "this tag contains text" or "this tag contains these subtags in this order, those are optional, those required and those can be repeated".

I don't mind the allowed values of attributes or tags or anything like that.

If everything else fails does anyone know of a predigested simplified XML Schema description I could peruse to write something like that myself.

This is for a system that exports data in many different formats, not only XML. For XML it has a DTD parser that builds a tree of tags and subtags which is then used to 1) present the system admins with a template into which they map the fields defined within the system and 2) generate the XML. While it might be beneficial to be able to import at least some of the value validations from the Schema it's not something that we would have time and pressing-enough need to do.

As some clients only provide a XML Schema and not DTD or examples we'd like to be able to work with XML Schema. Or rather we'd rather not, but are forced to.

Replies are listed 'Best First'.
Re: XML Schemata to DTD or simplified datastructure
by planetscape (Chancellor) on Dec 20, 2007 at 12:21 UTC
Re: XML Schemata to DTD or simplified datastructure
by eserte (Deacon) on Dec 17, 2007 at 20:58 UTC
    You can try trang to convert from one schema representation into another. It supports DTD, Relax NG (which is actually human-readable and -writable, a rare thing in the XML world!) and XML schema.

      That sounded like just the thing except that

      A schema written in any of the supported schema languages can be converted into any of the other supported schema languages, except that W3C XML Schema is supported for output only, not for input.
      :-(((

      I agree completely on your Relax NG comment.

      So it seems I will have to do something like that myself. :-( I'll keep you all posted.

Re: XML Schemata to DTD or simplified datastructure
by pKai (Priest) on Dec 17, 2007 at 22:59 UTC

    XSD (XML Schema) is XML, so for transforming it to something else XSLT is a prime candidate.

    It sounds to me that you are O.K. with some adhoc extraction, though. Maybe you can get away for that with your very own XML::Rules?

Re: XML Schemata to DTD or simplified datastructure
by msbalaji (Chaplain) on Dec 18, 2007 at 07:00 UTC

    Hi

    You may use "XML Authority" from TIBCO Extensibility converts DTDs into Schema and other formats and this as well as show report like root element, attributes, etc. more tools on http://www.w3.org/XML/Schema

    Balaji