f



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

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

0
11/28/2006 2:12:01 AM
comp.lang.perl.misc 33233 articles. 2 followers. brian (1246) is leader. Post Follow

5 Replies
1564 Views

Similar Articles

[PageSpeed] 50


On Nov 28, 2:12 am, huntingseason...@gmail.com 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.

0
Brian
11/28/2006 1:43:08 PM
Brian McCauley wrote:
> On Nov 28, 2:12 am, huntingseason...@gmail.com 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

0
huntingseasonson
11/28/2006 6:44:55 PM
huntingseasonson@gmail.com wrote:
> Brian McCauley wrote:
> > On Nov 28, 2:12 am, huntingseason...@gmail.com 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.

0
Brian
11/28/2006 10:12:20 PM
> 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!

0
skye
11/28/2006 11:57:47 PM

On Nov 28, 11:57 pm, skye.s...@gmail.com 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.

0
Brian
11/29/2006 12:37:23 PM
Reply: