in reply to How to use xml schema in perl

I think you are talking in part about "XML Schema Inference", that is generating an XSD schema from an existing instance of XML. As far as I know there is no module on CPAN that provides this facility (though I would be delighted to be proved wrong.) The basic problem of schema inference (or extraction if you would rather) is described in this paper.

Personally if I need to generate a schema from an existing XML document I use the xsd.exe that is part of the .NET framework, this is also available for mono if you are not on Windows and the mono implementation is described here.

As for validating an instance against an existing schema, you have a choice - you can use XML::Validator::Schema or the facilities in XML::LibXML among others that you will have seen when you performed the search on CPAN as davorg suggested.

/J\

Replies are listed 'Best First'.
Re^2: How to use xml schema in perl
by maspalio (Scribe) on Aug 11, 2006 at 13:35 UTC
    Hi again,

    My two cents on the validation topic.

    I've tried XML::Validator::Schema lately and was not quite happy with it. To be fair, I don't remember what was actually the blocking item (maybe something like inclusion within the Schema itself). Anyway, it seems like nothing happened on this module for two years.

    XML::LibXML on the other hand only validates againts DTD and Relax-NG kind of schemas, although this is a good DOM library.

    Cheers,

    Xavier
      XML::LibXML has been able to validate schemas for a while now (see below)
        Hi,

        You are right, my mistake!

        Unfortunately, latest XML::LibXML/libxml2 combo core dumps on my box...

        Thanks for the tip anyway!

        Cheers,

        Xavier