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 "Koziol, Jason" <ja...@sap.com> on 2000/06/15 17:01:53 UTC

RE: Invalidating empty element and returning line and column numb er

What is wrong is that it seems like I'm missing something.

For example, I'm in SAXPrint, and I want to modify the following method

void SAXPrintHandlers::endElement(const XMLCh* const name)
{
    cout << "</" << StrX(name) << ">";
}

so that it also prints out the line and column. My instincts, based on
whatever experience or lack of experience they may be, tell me I should
be able to do this in short order. But everything I can think of
involves a seemingly disproportionate amount of effort. Maybe you can 
tell me what you would do here?

A colleague promised me that you all would probably assume I was stupid.
That is just fine with me. :-)

BTW I am working in Win32.

Thanks

-----Original Message-----
From: Dean Roddey [mailto:droddey@charmedquark.com]
Sent: Wednesday, June 14, 2000 6:10 PM
To: xerces-c-dev@xml.apache.org
Subject: Re: Invalidating empty element and returning line and column
number


The locator is implemented in the most recent code, so it will work in the
upcoming release. But, the locator is really just the reader manager (which
implements the Locator interface.) The reader manager stuff obviously works,
since that's where all the line/col info comes from that are in any error
messages. What exactly do you feel is wrong?

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

"You young, and you gotcha health. Whatchoo wanna job fer?"


----- Original Message -----
From: "Koziol, Jason" <ja...@sap.com>
To: <xe...@xml.apache.org>
Sent: Wednesday, June 14, 2000 9:45 AM
Subject: Invalidating empty element and returning line and column number


> Using Xerces c version 1.1, SAX Parser
>
> I'm trying to validate an element as not being empty, and log information
> about its specific location in the xml file. The contents of the element
are
> destined for a key text field in a table, and must therefore have some
> content (but not necessarily unique).
>
> I would like to avoid using attributes, unless they speak to this need
> exactly. I have tried to use an ATTLIST store number ELEMENT #REQUIRED,
and
> while it appeared to exhibit the correct behavior, the error thrown had
> incorrect line and column numbers.
>
> Generally there seems to be a problem getting line and column information
> out of Xerces, as the setLocator method and Locator class seem to be
> non-functional, and the ReaderMgr, which does store the information, is
> non-cooperative.
>
> Am I missing something? Please help!!
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org

Re: Invalidating empty element and returning line and column number

Posted by Dean Roddey <dr...@charmedquark.com>.
In the upcoming release, you'll just intercept the setLocator() method and
remember that locator object and ask it for that information. In the current
code, you would probably want to do something in the constructor for your
document handler where you store a pointer to the reader manager.

// Inside your document handler constructor
ReaderMgr* fRdrMgr = &fMyParser.getScanner().getReaderMgr();

// Inside some subsquent event
fRdrMgr->getLineNumber();
fRdrMgr->getColumnNumber();
....


That's not as convenient as it will be when you can just get the locator,
but its not terribly onerous either. Don't know why your friend told you
that we would think you are stupid. I would assume that he had some belief
and we didn't agree and perhaps he interpreted that as us thinking he was
stupid or something. I dunno, but I only think someone is stupid if they ask
a question that is like the second answer in the FAQ or something like that.

Note that I'm going by the current code, so I might have flubbed something
relative to the existing 3.1.0/1.1.0 release. If the getLineNumber() and
getColumnNumber() methods aren't there on reader manager in that release, do
this:

fRdrMgr->getCurrentReader()->getColumnNumber();
fRdrMgr->getCurrentReader()->getLineNumber();

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

"You young, and you gotcha health. Whatchoo wanna job fer?"


----- Original Message -----
From: "Koziol, Jason" <ja...@sap.com>
To: <xe...@xml.apache.org>
Sent: Thursday, June 15, 2000 8:01 AM
Subject: RE: Invalidating empty element and returning line and column number


> What is wrong is that it seems like I'm missing something.
>
> For example, I'm in SAXPrint, and I want to modify the following method
>
> void SAXPrintHandlers::endElement(const XMLCh* const name)
> {
>     cout << "</" << StrX(name) << ">";
> }
>
> so that it also prints out the line and column. My instincts, based on
> whatever experience or lack of experience they may be, tell me I should
> be able to do this in short order. But everything I can think of
> involves a seemingly disproportionate amount of effort. Maybe you can
> tell me what you would do here?