"Geert Theys" <[EMAIL PROTECTED]> writes:

> > If you've set DoSchema, it will use a schema to validate the document,
> > if you haven't it will expect a DTD.
> >
> 
> this is the header of the XML I receive:
> <!DOCTYPE PXMLServiceRequest SYSTEM "D:\DTD\PXMLServiceRequest.dtd">
> 
> But the DTD is not in that place off course. Where in the program do I set
> where the DTD is?
> 
> In my other code I do(just to illustrate what I want):
> 
> use strict;
> use XML::LibXML;
> 
> # Here I read my dtd in a string
> my $dtdstr = do {
>     local $/;
>     open(DTD, 'XMLS/PXMLStatusMessage.dtd') || die $!;
>     my $str = <DTD>;
>     close DTD;
>     $str;
> };
> # Set validation on
> XML::LibXML->validation(1);
> 
> # pars XML and DTD
> my $dtd1 = XML::LibXML::Dtd->parse_string($dtdstr);
> my $xml1 = XML::LibXML->new->parse_file('XMLS/PXMLStatusMessage.xml');
> 
> # To ways to check validation. Both work rather well :)
> if(!$xml1->is_valid($dtd1)) {
>     print "Our XML is not valid!!!\n";
> }
> 
> eval { $xml1->validate($dtd1); }; print $@ if $@;

Aha!! Now I finally understand (amazing how dense module maintainers
can be sometimes ;-)

Yes, I agree completely this type of high-level documentation is
completely missing from Xerces-P/C/J

In Xerces, Parser::parse() does all the validation for you without
needing to call the is_valid() method. (Just curious, why set
validation(1) when you call is_valid() by hand? And what is the
difference between validate() and is_valid()?).

Depending on which subclass of Parser you are using (i.e. DOMParser,
SAXParser, SAX2XMLReader, or IDOMParser) you would handle things
slightly differently for the steps after handling the DTD, but they
all handle DTD's the same.

The simplest way to deal with DTD's is to use SYSTEM and make sure
that the DTD's are where you say they will be. If not, then ou need to
setup an EntityResolver. I believe this is all part of the XML spec,
and so, although the other library is convenient, it's not actually
implementing the spec...

I'm afraid to say that Xerces.pm has not yet implemented
EntityResolver's completely (oh the shame ....). All the framework is
there. I just need to hook it up. I'll try to cut a release while I'm
here at the Open Source conference.

Sorry,
jas.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to