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

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

  1. Guest

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

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

    Code:

    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>.
    at
    /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/XML/LibXML/SAX.pm
    line 64
    at ./transform.pl 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.

    Code:

    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
     
    , Nov 28, 2006
    #1
    1. Advertising

  2. On Nov 28, 2:12 am, wrote:
    > Both XML::LibXML::Schema and XML::Validator::Schema error when I
    > attempt to validate, yet the XML and XSD files appear to be perfectly
    > fine.


    > Both fXML and XSD files are quite long, but I will post if necessary.


    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
    #2
    1. Advertising

  3. Guest

    Brian McCauley wrote:
    > On Nov 28, 2:12 am, wrote:
    > > Both XML::LibXML::Schema and XML::Validator::Schema error when I
    > > attempt to validate, yet the XML and XSD files appear to be perfectly
    > > fine.

    >
    > > Both fXML and XSD files are quite long, but I will post if necessary.

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


    Ok, the xml: http://huntingseasonson.com/TV.xml

    and the xsd: http://huntingseasonson.com/TV.xsd

    Thanks
     
    , Nov 28, 2006
    #3
  4. wrote:
    > Brian McCauley wrote:
    > > On Nov 28, 2:12 am, wrote:
    > > > Both XML::LibXML::Schema and XML::Validator::Schema error when I
    > > > attempt to validate, yet the XML and XSD files appear to be perfectly
    > > > fine.

    > >
    > > > Both fXML and XSD files are quite long, but I will post if necessary.

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

    >
    > Ok, the xml: http://huntingseasonson.com/TV.xml
    >
    > and the xsd: http://huntingseasonson.com/TV.xsd


    I suspect XML::LibXML::Schema may be getting confused by the explicit
    empty namepace declaration.

    <xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    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:complexType>
    <xs:simpleContent>
    <xs:extension base="xs:string">
    <xs:attribute name="type" use="required">
    <xs:simpleType>

    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
    attributes.
     
    Brian McCauley, Nov 28, 2006
    #4
  5. Guest


    > I suspect XML::LibXML::Schema may be getting confused by the explicit
    > empty namepace declaration.
    >
    > <xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="package">


    Yup that was it.

    Thank you very much!
     
    , Nov 28, 2006
    #5
  6. On Nov 28, 11:57 pm, wrote:
    > > I suspect XML::LibXML::Schema may be getting confused by the explicit
    > > empty namepace declaration.

    >
    > > <xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    > > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="package">Yup that was it.

    >
    > Thank you very much!


    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 www.w3.org.
     
    Brian McCauley, Nov 29, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,640
    Markus
    Nov 23, 2005
  2. Ian Gregory
    Replies:
    1
    Views:
    524
  3. Olav
    Replies:
    3
    Views:
    4,337
  4. stiank81
    Replies:
    4
    Views:
    15,496
    stiank81
    Jun 26, 2005
  5. Rushi
    Replies:
    1
    Views:
    576
Loading...

Share This Page