Hi,
the XML example you provided is invalid. Note you have not closed
the PolicyFile tag. If you implement the error methods in your error
handler class you will get much more reasonable output that "aborted".
Check out DOMTreeErrorReporter in the samples for how to do this.
Gareth
On Thu, 20 Feb 2003, Axelle Apvrille (LMC) wrote:
> Hi all,
> I'm a newbie here so probably this one won't be too difficult for you...
> I'm trying to make my DOM parser parse a buffer containing an XML
> document (and not parse a file as in samples). I've seen that work with
> SAX, but with DOM, I get an 'Aborted' !
>
> % ./domparsetest
> Initialize the platform
> Instantiate the DOM Parser
> Create Error Handler
> Create XML document to parse
> <?xml version='1.0' encoding='ascii'?>
> <UpdatePolicy>
> <PolicyFile> /etc/toto.txt <PolicyFile>
> </UpdatePolicy>
>
> init membufIS
> Parse
> Aborted
> %
>
> ---
> Basically, I just build a XercesDOMParser, set the error handler, make a
> MemBufInputSource out of my XML buffer, and parse it:
>
> try
> {
> XMLPlatformUtils::Initialize();
> }
> catch(const XMLException& toCatch)
> {
> ...
> }
>
> XercesDOMParser *m_Parser = new XercesDOMParser;
> m_Parser->setValidationScheme(XercesDOMParser::Val_Auto);
> m_Parser->setDoNamespaces(false);
> m_Parser->setDoSchema(true);
> m_Parser->setValidationSchemaFullChecking(false);
>
> ErrorHandler *m_ErrorHandler = (ErrorHandler *) new HandlerBase();
> m_Parser->setErrorHandler(m_ErrorHandler);
>
> const char *buffer = "<?xml version='1.0' encoding='" "ascii" "'?>\n\
> <UpdatePolicy>\n\
> <PolicyFile> /etc/toto.txt <PolicyFile>\n\
> </UpdatePolicy>\n";
>
> MemBufInputSource* memBufIS = new MemBufInputSource((const XMLByte*)
> buffer,
> strlen(buffer),
> bufId);
> try
> {
> m_Parser->parse(*memBufIS); <------ I get an 'Aborted' from here !
> }
> catch (const XMLException& toCatch)
> {
> ...
> }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]