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

Hi all
I am trying to move on from using Perl as a glue/process control/regex tool to trying to process data using XML schemas. However, I can't seem to find a way to conveniently parse an XML schema in Perl. Ideally I would like to parse schema to create a database and populate the database using XML files and comparing them to the schema.
Any suggestions/advice out there?

mndoci

"What you do in this world is a matter of no consequence. The question is, what can you make people believe that you have done?"-Sherlock Holmes in 'A study in scarlet'

Replies are listed 'Best First'.
Re: Parsing XML schema
by footpad (Abbot) on Nov 04, 2001 at 06:16 UTC
Re: Parsing XML schema
by mirod (Canon) on Nov 05, 2001 at 16:41 UTC

    The only module that deals with W3C schemas is Andy Wardley's XML::Schema, which is not available anywhere (I guess you can contact Andy if you need it). And in any case it does not parse W3C shemas, so you are really out of luck!.

    That said you have a couple of options:

    • treat the schema as just XML and write the appropriate code to generate the data base. This is probably quite difficult if you want to be really general, but I am sure lots of people would be interested by a module that does this. If you feel like contibuting to CPAN, here is your chance!
    • convert the schema to a DTD (there are tools for this, such as XML Authority, look at the DTD/Schema Editors list for other alternatives) and proceed from there with a module that understands DTDs (XML::Parser, XML::DOM, probably XML::XPath), easier but DTDs might not suit your purpose as they don't have the content typing features that W3C schemas offer,
    • use schematron (with XML::Schematron), an alternate XML schema system, I don't know that much about it but you might want to investigate it.
      Thank you for your reply. I ended up trying out the first option in combo with XML::Twig. Nothing fancy but it seems to work.

      "What you do in this world is a matter of no consequence. The question is, what can you make people believe that you have done?"-Sherlock Holmes in 'A study in scarlet'