Re: [Htmlparser-user] Node object and line number
Brought to you by:
derrickoswald
From: Somik R. <so...@ya...> - 2003-03-12 20:33:31
|
Hi Marc, What you say makes sense. A node should know which line it began and which line it ended. The reason we don't do this already, we only used it to pick up the next node, which is on the same or the next line. Like you said, doing this is not hard as the reader stores the line info. It should be in one of the integration releases (do add this as a feature request so we don't forget). Regards, Somik --- Marc Novakowski <ma...@ke...> wrote: > Hello, > > I just thought I'd start out by thanking everyone > who has worked on the htmlparser project. I'm been > using it for only a few days now but the > functionality it provides has saved me amazing > amounts of work. So far I have found it very easy > to integrate into my project. > > I am using the htmlparser library for what I'm > guessing is a less traditional application. I've > integrated it into a custom servlet filter which > takes a processed JSP page and parses it for > "custom" tags which I've defined. Using custom > scanner and tag, I'm able to replace my "custom > tags" with appropriate HTML/Javascript in the > toHtml() method for each tag. However, I'd like to > add some validation to my code to ensure certain > constraints are observed, such as certain tags which > REQUIRE a "name" attribute to be defined. I've done > this easily enough by adding a "verify()" method to > my custom tags and throwing a ParserException if a > constraint is violated. > > However, just throwing an exception does not help > the webpage developer determine where the problem is > in the HTML. What would REALLY help me is if the > Node object had a method on it called something like > getLineNumber() which returned the line number at > which that node was parsed. > > I've looked at the source code and this seems > feasible. The NodeReader class keeps track of the > current line number as it finds nodes in the HTML. > Maybe the constructor for a Node() object could take > in one more argument, the lineNumber, so that it > could expose that lineNumber in a public method. > > Does this sound like a hairbrained idea? Has this > ever come up before? > > Thanks again, > Marc Novakowski > > > ------------------------------------------------------- > This SF.net email is sponsored by:Crypto Challenge > is now open! > Get cracking and register here for some mind > boggling fun and > the chance of winning an Apple iPod: > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com |