Validation with XSD using XML::LibXML::Schema, and XML::Validator::Schema

Discussion in 'Perl Misc' started by huntingseasonson, Nov 28, 2006.

  1. Both XML::LibXML::Schema and XML::Validator::Schema error when I
    attempt to validate, yet the XML and XSD files appear to be perfectly

    XML::LibXML::Schema errors with:
    Element '{}element', attribute 'ref':
    References from this schema to components in the namespace '' are not
    allowed, since not indicated by an import statement.


    my $parser = XML::LibXML->new();
    my $doc = $parser->parse_file("TV.xml");
    my $v = XML::LibXML::Schema->new(location=>"TV.xsd");
    eval { $v->validate($doc); };
    die $@ if $@;


    XML::Validator::Schema errors with:
    Found <simpleType> illegally combined with <complexType>.
    line 64
    at ./ line 234

    <simpleType> is allowed to be nested withen a <complexType> correct? As
    the examples I have seen on the w3c's schema tutorial nest them.
    LibXML's error, well I thought a "ref" to a element withen the same
    namespace (none) is perfectly ok.


    my $v = XML::Validator::Schema->new(file=>"TV.xsd");
    my $p = XML::SAX::parserFactory->parser(handler=>$v);
    eval { $p->parse_uri("TV.xml") };
    die $@ if $@;

    Both fXML and XSD files are quite long, but I will post if necessary.
    Im not sure these errors are do to a problem with Perl's
    implementation, in javax.xml.validation.Validator they validated ok;
    maybe Java's implementation is more relaxed....?

    Thanks in advance
    huntingseasonson, Nov 28, 2006
    1. Advertisements

  2. I can't really see how we can comment if you don't make them available
    to us.

    If you can't manage to reduce them to a minimal (but complete) test
    case then rather than actually posting them it may be better to put
    them somewhere public and post a link.
    Brian McCauley, Nov 28, 2006
    1. Advertisements

  3. huntingseasonson, Nov 28, 2006
  4. I suspect XML::LibXML::Schema may be getting confused by the explicit
    empty namepace declaration.

    <xs:schema xmlns="" xmlns:xs=""
    xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="package">

    XML::Validator::Schema only supports a subset of XSD. I can't
    immediately see what in your TV.xsd goes beyond what it supports. It
    looks like it's mistaking getting confused here...

    <xs:extension base="xs:string">
    <xs:attribute name="type" use="required">

    Looking in XML::Validator::Schema::parser it seems not to consider the
    possiblity that <xs:attribute> has content so it sees <xs:simpleType>
    as being within the <xs:complexType>. (The <xs:simpleContent> and
    <xs:extension> are handled as specialization of the <xs:complexType>).

    I guess XML::Validator::Schema::parser only supports named types for
    Brian McCauley, Nov 28, 2006
  5. huntingseasonson Guest

    Yup that was it.

    Thank you very much!
, Nov 28, 2006
  6. Not that this as anything to do with Perl, but it would be interesting
    to know if this is a bug in LibXML or if the XSD was at fault. I'm
    inclined to believe the former but I wasn't able to convince myself one
    way or another from a quick look at
    Brian McCauley, Nov 29, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.