Dear Jason,
On Tue, 22 Jun 2004, Jason E. Stewart wrote:
> Chris Cheung <[EMAIL PROTECTED]> writes:
>
> > My project uses both DOM parsing and SAX parsing. DOM parsing is for
> > some small-scale XML configuration file and the application will
> > traverse the DOM Tree directly using the API of XML-Xerces. We use
> > SAX for parsing some VERY LARGE XML data file which transform the
> > XML data into some Perl data structure with filtering.
> >
> > I will try to list all API we are currently as soon as possible.
>
> There are 5 major API's that I need to consider:
>
> * XercesDOMParser
> * DOMBuilder
> * SAXParser
> * SAX2XMLReader
> * DOMWriter
>
Thank you very much for your help.
The APIs which our project uses are listed as follows.
(Sorry that I just grep them from source code, but the class and method
name should be obvious)
If you find that we used Xerces-Perl inappropreately somewhere or have
some better suggestion, please kindly let us know.
DOM parsing:
------------
1. my $parser = XML::Xerces::XercesDOMParser->new();
2. $parser->setDoNamespaces(1);
3. $parser->setCreateEntityReferenceNodes(1);
4. $parser->setDoSchema(1);
5. $parser->setErrorHandler(...);
6. $parser->setValidationScheme($XML::Xerces::AbstractDOMParser::Val_Auto);
7. $parser->parse(XML::Xerces::MemBufInputSource->new($xmlString));
8. $parser->parse($xmlFile);
9. my $doc = $parser->getDocument();
SAX parsing:
------------
1. my $parser = XML::Xerces::XMLReaderFactory::createXMLReader();
2. $parser->setFeature("$XML::Xerces::XMLUni::fgSAX2CoreNameSpaces", 1);
3. $parser->setFeature("$XML::Xerces::XMLUni::fgSAX2CoreValidation",1);
4. $parser->setFeature("$XML::Xerces::XMLUni::fgXercesDynamic", 1);
5. $parser->setFeature("$XML::Xerces::XMLUni::fgXercesSchema", 1);
6. $parser->setErrorHandler(...);
7. $parser->setContentHandler(...);
8. $parser->parse(XML::Xerces::MemBufInputSource->new($xmlString));
9. $parser->parse(XML::Xerces::LocalFileInputSource->new($xmlFile));
XML Serialization:
------------------
1. my $domImpl =
XML::Xerces::DOMImplementationRegistry::getDOMImplementation('LS');
2. my $writer = $domImpl->createDOMWriter();
3. $writer->canSetFeature('format-pretty-print',1);
4. $writer->setFeature('format-pretty-print',1);
5. my $target = XML::Xerces::MemBufFormatTarget->new();
6. $writer->writeNode($target, $doc);
7. $target->getRawBuffer();
--
Best Regards,
Chris Cheung
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]