You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by ruud waij <wa...@wt.tno.nl> on 2001/01/02 11:21:04 UTC

Re: SAX Locator

Dean Roddey wrote:

> At the start of each SAX parse, you are passed a pointer to an object that
> implements the Locator interface. You don't own it, you just get to use it
> for the length of the parse. That object can implement anything it wants,
> but you only see it as a Locator. Don't assume its anything else, or try to
> cast it to what you think it might really be.
>

'you are passed a pointer'  through which function call?

The only function I could find is:

               void DocumentHandler::setDocumentLocator (
                                                    const Locator * const
                                                    locator ) [pure
                                                    virtual]

                Receive an object for locating the origin of SAX document
events. ...

To this function you would have to pass an &locator which you instantiated
yourself. This of course is not possible because class Locator is pure virtual.
Besides, the Locator parameter above is heavily 'const'ed.

Which SAX interface function returns the Locator pointer?

ruud


Re: SAX Locator

Posted by Dean Roddey <dr...@charmedquark.com>.
That's not really correct, though it will work technically. The SAX
DocumentHandler interface provides a callback via which the parse gives you
a pointer to the locator object. You store that pointer and use it until the
document ends. The next time, you might get a completely different object.
This is the portable SAX way of doing it.

--------------------------
Dean Roddey
The CIDLib C++ Frameworks
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"It takes two buttocks to make friction"
    - African Proverb


----- Original Message -----
From: "Jim Cole" <jc...@tecomac.com>
To: <xe...@xml.apache.org>
Sent: Tuesday, January 02, 2001 1:51 PM
Subject: Re: SAX Locator


> >'you are passed a pointer'  through which function call?
> >
>
> Hi - I don't know if it is the *right* way to do things, but I did the
> following to get a Locator.
>
> SAXParser parser;
>
> const Locator* posLocator = (parser.getScanner()).getLocator();
>
> This seems to work.
>



Re: SAX Locator

Posted by Jim Cole <jc...@tecomac.com>.
ruud waij's bits of Tue, 2 Jan 2001 translated to:

>Dean Roddey wrote:
>
>> At the start of each SAX parse, you are passed a pointer to an object that
>> implements the Locator interface. You don't own it, you just get to use it
>> for the length of the parse. That object can implement anything it wants,
>> but you only see it as a Locator. Don't assume its anything else, or try to
>> cast it to what you think it might really be.
>>
>
>'you are passed a pointer'  through which function call?
>

Hi - I don't know if it is the *right* way to do things, but I did the
following to get a Locator.

SAXParser parser;

const Locator* posLocator = (parser.getScanner()).getLocator();

This seems to work.


Jim