[Htmlparser-user] Node object and line number
Brought to you by:
derrickoswald
From: Marc N. <ma...@ke...> - 2003-03-12 19:15:28
|
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 |