[xsd-users] Custom DOMLSParser

Carlos Wong carloswong54 at gmail.com
Wed Jun 8 11:02:45 EDT 2022


Hi Boris,

Thank you for the prompt response.

It turns out my issue was resolved by calling the DOMLSParserImpl
constructor from the initialization list.

I was calling it directly from the constructor body.

I will give your suggestion to directly create a custom_dom_LS_parser_impl
a shot.

Thanks again,

Carlos

On Wed, Jun 8, 2022 at 10:51 AM Boris Kolpackov <boris at codesynthesis.com>
wrote:

> Carlos Wong <carloswong54 at gmail.com> writes:
>
> > But I can only either make the embedded binary representation work or my
> > customer error handler. I have run out of ideas, please any feedback
> and/or
> > suggestions would be greatly appreciated.
>
> I tried to follow your code and AFAICS, here is what happens: you call
> DOMImplementationRegistry::getDOMImplementation() which returns some
> Xerces-provided instance of DOMImplementation. Then you cast it (with
> a C-style cast) to your custom_dom_implementation_impl type, even though
> it's not. Then you call createLSParser(), which (probably) ends up
> calling Xerces' original implementation and you get Xerces' original
> DOMLSParserImpl. Or you call createCustomLSParser(), which is wrong,
> but by the looks of it, it should return you an instance of your
> custom_dom_LS_parser_impl (because it's not a virtual function and
> you don't reference any data member).
>
> Why don't you get rid of all this DOMImplementation stuff and create
> an instance of your custom_dom_LS_parser_impl directly:
>
> xml::dom::auto_ptr<custom_dom_LS_parser_impl> parser(
>   new (manager) custom_dom_LS_parser_impl(0, manager, gramPool));


On Wed, Jun 8, 2022 at 10:51 AM Boris Kolpackov <boris at codesynthesis.com>
wrote:

> Carlos Wong <carloswong54 at gmail.com> writes:
>
> > But I can only either make the embedded binary representation work or my
> > customer error handler. I have run out of ideas, please any feedback
> and/or
> > suggestions would be greatly appreciated.
>
> I tried to follow your code and AFAICS, here is what happens: you call
> DOMImplementationRegistry::getDOMImplementation() which returns some
> Xerces-provided instance of DOMImplementation. Then you cast it (with
> a C-style cast) to your custom_dom_implementation_impl type, even though
> it's not. Then you call createLSParser(), which (probably) ends up
> calling Xerces' original implementation and you get Xerces' original
> DOMLSParserImpl. Or you call createCustomLSParser(), which is wrong,
> but by the looks of it, it should return you an instance of your
> custom_dom_LS_parser_impl (because it's not a virtual function and
> you don't reference any data member).
>
> Why don't you get rid of all this DOMImplementation stuff and create
> an instance of your custom_dom_LS_parser_impl directly:
>
> xml::dom::auto_ptr<custom_dom_LS_parser_impl> parser(
>   new (manager) custom_dom_LS_parser_impl(0, manager, gramPool));
>


More information about the xsd-users mailing list