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

> hehe,
> 
> what you told me I already did. 

Sorry about that.

> I read the examples in samples and in t :) but don't really
> understand the validation scheme?  It doesn't use a DTD for
> validation but scheme?
> 
> I read the C docs too, but my perl skills are a lot better then my c.
> I figured out how to use the xerces as parser, but on the DTD end I'm
> stuck....

I had hoped that they were more clear... Any suggestions as to how to
make them more useful are welcome.

Let's pick apart DOMCount.pl for a bit:

  my $parser = XML::Xerces::DOMParser->new();
  $parser->setValidationScheme ($validate);
  $parser->setDoNamespaces ($namespace);
  $parser->setCreateEntityReferenceNodes(1);
  $parser->setDoSchema ($schema);

First we create the parser object, then we set whatever parse flags we
need. Don't confuse ValidationScheme with scheme, it can take three
values:

  * $XML::Xerces::DOMParser::Val_Always
  * $XML::Xerces::DOMParser::Val_Never
  * $XML::Xerces::DOMParser::Val_Auto

If you've set DoSchema, it will use a schema to validate the document,
if you haven't it will expect a DTD.

  my $error_handler = XML::Xerces::PerlErrorHandler->new();
  $parser->setErrorHandler($error_handler);

It's always a good idea to use an error handler. Otherwise parsing
just stops with no error message, not too friendly.


  $parser->parse (XML::Xerces::LocalFileInputSource->new($file));

Currently, only one of the parse() methods is available, so you need
to create an InputSource. parse() does all the work.

  my $doc = $parser->getDocument ();
  my $element_count = $doc->getElementsByTagName("*")->getLength();

Once you're done, getDocument() will give you the Document object,
with which you can begin picking apart the information...

HTH,
jas.



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

Reply via email to