From this page ( perl-xml.sourceforge.net/perl-sax/sax-2.... ), it seems straight-forward.. Under Exceptions it says.
From this page (perl-xml.sourceforge.net/perl-sax/sax-2....), it seems straight-forward.. Under Exceptions it says: If the exception is raised due to parse errors, these properties are also available: ColumnNumber The column number of the end of the text where the exception occurred. LineNumber The line number of the end of the text where the exception occurred. PublicId The public identifier of the entity where the exception occurred.
SystemId The system identifier of the entity where the exception occurred. Looks like you can get a line number and column number if a parsing exception or validation error occurs. As it says on the page I mentioned: "Conformant XML parsers are required to abort processing when well-formedness or validation errors occur."
Validation would include attribute names, wouldn't it?
Thanks Spaceghost, but well-formedness errors are already diagnosed by the parser with location info. I should have been more precise: I would like to point out, for example, invalid attribute names, invalid values, in other words, errors in the semantics of the data, not the syntax. JJ – Jens Mar 7 at 18:55 I paraphrased the page.. they also include validation errors as a source of exceptions.
– Spaceghost Mar 7 at 19:20 Validation can only do very limited checking, I need to do much more. Think of a numeric attribute value that must be a prime. I'd like to print "Line 200: attribute n='42' is not a prime".
I'm sure the parser state contains line/column/offset somewhere when start_element is callled. But how do I access it? – Jens Mar 7 at 19:49 Ok, you want to find the problem and then report it?
Then you need to throw an error when you find, for example, a non-prime numeric attribute value which will be caught by the exception hadnling mechanism and, presto, you get a line number. – Spaceghost Mar 7 at 19:57 Hmm. Calling $aSelf->error("foo") is a no-op; it's another method like start_element, which, if not implemented by the EventHandler package, has a dummy no-op implementation.
With an expat parser it would be as easy as referencing $aSelf->current_line. There's nothing similar for SAX with libxml? How would you throw the exception you suggested?
Thanks four your patience with me :-) – Jens Mar 7 at 20:46.
I switched to using XML::Parser::PerlSax. This module has a method location() to return a hash with file, line, colum position that does the trick. See search.cpan.org/~kmacleod/libxml-perl-0.....
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.