Free CL sourcecode to parse HTML, RFC822 headers, etc.? 
Author Message
 Free CL sourcecode to parse HTML, RFC822 headers, etc.?

Does anybody know of any public-domain or other freely
available Common-LISP sourcecode for parsing HTML files into
a structured form, for example <bold>text</bold> should
parse as something like (bold "text") instead of as
(start-bold)"text"(end-bold), and <a href="url">text</a>
should parse as something like (href "url" "text") instead
of as (start-href "url") "text" (end-href) likewise all
other semantically nested meaning should be represented as
nested s-expressions rather than sequences of start and end
forms as the original HTML shows?

If such is not available online, how about just the surface
parse as a sequence of start-something and end-something,
which a subsequent LISP program could then convert to nested
form?

Does anybody know of any public-domain or other freely
available Common-LISP sourcecode for parsing e-mail headers,
such as Received lines correctly parsed into the from part
and the by part with each part properly nested?

More generally, does there exist any archive of
freely-available Common-LISP sourcecode which is indexed by
topic (kind of task performed, kind of data processed) and
for which there's a WebServer application that is a search
engine whereby somebody can type in a description such as I
gave in the first and third paragraphs above and the server
then automatically finds the most relevant matches?

If a fully indexed LISP-source archive with search engine
isn't available, then what about just a LISP-source archive
with an index by keywords or topics that is easily readable
by a LISP program so that I could write the search engine
myself?



Thu, 15 Jul 2004 04:07:42 GMT  
 Free CL sourcecode to parse HTML, RFC822 headers, etc.?

Quote:

> Does anybody know of any public-domain or other freely
> available Common-LISP sourcecode for parsing HTML files

http://opensource.franz.com/xmlutils

Quote:
> More generally, does there exist any archive of
> freely-available Common-LISP sourcecode which is indexed by
> topic

http://ww.telent.net/cliki

--
Regards,
Alexey Dejneka



Thu, 15 Jul 2004 14:55:14 GMT  
 Free CL sourcecode to parse HTML, RFC822 headers, etc.?

Quote:
> Does anybody know of any public-domain or other freely
> available Common-LISP sourcecode for parsing HTML files into
> a structured form, for example <bold>text</bold> should

Check `cllib', which is part of CLOCC (Common Lisp Open Code Collection):

  http://clocc.sourceforge.net/

It comes with some HTML parsing code. Also see the Web section of CLiki...

Quote:
> More generally, does there exist any archive of
> freely-available Common-LISP sourcecode which is indexed by

The closest thing is CLiki:

  http://ww.telent.net/cliki

Quote:
> If a fully indexed LISP-source archive with search engine
> isn't available, then what about just a LISP-source archive
> with an index by keywords or topics that is easily readable
> by a LISP program so that I could write the search engine
> myself?

There is the CMU Common Lisp Repository, but it is no longer being
maintained:

  ftp://ftp.cs.cmu.edu/user/ai/lang/lisp/

Paolo
--
EncyCMUCLopedia * Extensive collection of CMU Common Lisp documentation
http://web.mclink.it/amoroso/ency/README
[http://cvs2.cons.org:8000/cmucl/doc/EncyCMUCLopedia/]



Thu, 15 Jul 2004 21:40:42 GMT  
 Free CL sourcecode to parse HTML, RFC822 headers, etc.?

Quote:


> > Does anybody know of any public-domain or other freely
> > available Common-LISP sourcecode for parsing HTML files

> http://www.*-*-*.com/

Note though that although parsing HTML should be a simple application
of a generic SGML (not XML, for that you need XHTML) parser, unless
you generate the HTML files yourself, it isn't:  There is all kind of
{*filter*}out there in the wild, that purports to be HTML (i.e. conforming
to some HTML DTD), and through heroic efforts on the part of the
browser writers does render OK.  So unless you can afford to tell 99%
percent of your users "Error: This is not HTML!", you'll need to handle
all sorts of erroneous stuff, like mis-matched start end end tags,
etc.  Generally parsing real-world HTML is probably akin to heuristic
natural language parsing, than it is to SGML parsing.

Regs, Pierre.

--

 The most likely way for the world to be destroyed, most experts agree,
 is by accident. That's where we come in; we're computer professionals.
 We cause accidents.                           -- Nathaniel Borenstein



Fri, 16 Jul 2004 00:07:25 GMT  
 Free CL sourcecode to parse HTML, RFC822 headers, etc.?

Quote:


>> > Does anybody know of any public-domain or other freely
>> > available Common-LISP sourcecode for parsing HTML files

>> http://www.*-*-*.com/

>Note though that although parsing HTML should be a simple application
>of a generic SGML (not XML, for that you need XHTML) parser, unless
>you generate the HTML files yourself, it isn't:  There is all kind of
>{*filter*}out there in the wild, that purports to be HTML (i.e. conforming
>to some HTML DTD),

Wrong DTD implies either SGML of XML. HTML is not expressible in
either.
Quote:
> and through heroic efforts on the part of the
>browser writers does render OK.  So unless you can afford to tell 99%
>percent of your users "Error: This is not HTML!", you'll need to handle
>all sorts of erroneous stuff, like mis-matched start end end tags,
>etc.

Bullshit. None of this is erroneous. From the perspective of
SGML or XML it is. From the perspective of HTML it is perfectly legal.
Quote:
> Generally parsing real-world HTML is probably akin to heuristic
>natural language parsing, than it is to SGML parsing.

If you have an XML parser and not a real HTML parser, then you
probably would want to go to w3.org . There is a utility there that
translates from HTML to XHTML.


Fri, 16 Jul 2004 01:52:31 GMT  
 Free CL sourcecode to parse HTML, RFC822 headers, etc.?

Quote:



> >> > Does anybody know of any public-domain or other freely
> >> > available Common-LISP sourcecode for parsing HTML files

> >> http://www.*-*-*.com/

> >Note though that although parsing HTML should be a simple application
> >of a generic SGML (not XML, for that you need XHTML) parser, unless
> >you generate the HTML files yourself, it isn't:  There is all kind of
> >{*filter*}out there in the wild, that purports to be HTML (i.e. conforming
> >to some HTML DTD),
> Wrong DTD implies either SGML of XML. HTML is not expressible in
> either.

Did you actually look at the relevant W3C recommendations and RFCs?

First of all:  I never claimed that DTD "implies" SGML, because that
would be utter rubbish.  It is just a fact that since 1994 (at least)
HTML is defined as an SGML application, with reference to an SGML DTD.
To quote from RFC 1866:

<quote>
   HTML is an application of ISO Standard 8879:1986, "Information
   Processing Text and Office Systems; Standard Generalized Markup
   Language" (SGML). The HTML Document Type Definition (DTD) is a formal
   definition of the HTML syntax in terms of SGML.

   This specification also defines HTML as an Internet Media
   Type[IMEDIA] and MIME Content Type[MIME] called `text/html'. As such,
   it defines the semantics of the HTML syntax and how that syntax
   should be interpreted by user agents.
</quote>

<quote>
   A document is a conforming HTML document if:

        * It is a conforming SGML document, and it conforms to the
        HTML DTD (see 9.1, "HTML DTD").

  [...]
</quote>

Similar language can be found in all relevant W3C recommendations,
too.

So to restate the obvious: _Valid_ HTML should be parsable with any
conforming SGML parser.  You can't parse valid HTML with an XML
parser, because HTML makes use of features of SGML which are not
present in XML.  However using a SGML parser, it is fairly simple to
convert valid HTML to valid XHTML, which can be parsed with any
conforming XML parser.

But that isn't the issue here at all:  "HTML" as found on the WWW is
very seldom conforming to any kind of standard DTD (and isn't even
well-formed in the XML sense):

Quote:
> >all sorts of erroneous stuff, like mis-matched start end end tags,
> >etc.
> Bullshit. None of this is erroneous. From the perspective of
> SGML or XML it is. From the perspective of HTML it is perfectly legal.

So you consider e.g.

<b><em>mismatch here:</b></em>

to be a perfectly legal HTML document fragment[1]?  Since none of the W3C
recommendations I'm aware of, nor RFC 1866 declares this to be valid,
you can surely point me to a specification for "HTML" that does.

Quote:
> > Generally parsing real-world HTML is probably akin to heuristic
> >natural language parsing, than it is to SGML parsing.

> If you have an XML parser and not a real HTML parser, then you
> probably would want to go to w3.org . There is a utility there that
> translates from HTML to XHTML.

That is a completely different problem, see above.

All in all I'd be very happy if you could tone down your language, and
give references which back your wild claims, instead.

Regs, Pierre.

Footnotes:
[1]  And yes, you will encounter lots of that kind of stuff in
     user-written HTML (and even some that's generated by borken HTML
     editors/generators).  While the general situation has improved
     somewhat in recent years, it is still abismal.

--

 The most likely way for the world to be destroyed, most experts agree,
 is by accident. That's where we come in; we're computer professionals.
 We cause accidents.                           -- Nathaniel Borenstein



Fri, 16 Jul 2004 03:12:32 GMT  
 Free CL sourcecode to parse HTML, RFC822 headers, etc.?

Quote:


> > > Does anybody know of any public-domain or other freely
> > > available Common-LISP sourcecode for parsing HTML files

> > http://www.*-*-*.com/

> Note though that although parsing HTML should be a simple application
> of a generic SGML (not XML, for that you need XHTML) parser, unless
> you generate the HTML files yourself, it isn't:  There is all kind of
> {*filter*}out there in the wild, that purports to be HTML (i.e. conforming
> to some HTML DTD), and through heroic efforts on the part of the
> browser writers does render OK.  So unless you can afford to tell 99%
> percent of your users "Error: This is not HTML!", you'll need to handle
> all sorts of erroneous stuff, like mis-matched start end end tags,
> etc.  Generally parsing real-world HTML is probably akin to heuristic
> natural language parsing, than it is to SGML parsing.

However, I believe stuffing crap-du-jour html found on the web through
tidy ( http://www.*-*-*.com/ ) usually results in something an SGML parser
won't {*filter*}on.

Cheers,
M.

--
  In that case I suggest that to get the correct image you look at
  the screen from inside the monitor whilst standing on your head.  
               -- James Bonfield, http://www.*-*-*.com/



Sat, 17 Jul 2004 00:03:38 GMT  
 Free CL sourcecode to parse HTML, RFC822 headers, etc.?

[snip]

Quote:
> Note though that although parsing HTML should be a simple application
> of a generic SGML (not XML, for that you need XHTML) parser, unless
> you generate the HTML files yourself, it isn't:  There is all kind of
> {*filter*}out there in the wild, that purports to be HTML (i.e. conforming
> to some HTML DTD), and through heroic efforts on the part of the
> browser writers does render OK.

I think it's a little more complicated. I.e., the standard behavior of
"ignoring tags you don't understand" (a SGML trope, I believe) conceals a
multitude of sins, at least for viewing purpose. Plus, the browser parsers
*introduced* several pervasive bugs (Netscape comment handling, is an
example, I forget for which versions).

Quote:
>  So unless you can afford to tell 99%
> percent of your users "Error: This is not HTML!", you'll need to handle
> all sorts of erroneous stuff, like mis-matched start end end tags,
> etc.  

Actually, for a fair number of cases, that's not so bad, because of
implied endtags. E.g.:

        <li>Bad end tag? </il>
        <li>No problem!</il>
        <li> standard sgml will insert a proper "</li>" before the
erronous one and then ignore the erroneous one.

Quote:
>Generally parsing real-world HTML is probably akin to heuristic
> natural language parsing,

Not for viewing. For extracting data (screen scraping), sure.

Quote:
> than it is to SGML parsing.

SGML parsing can be kinda {*filter*} :)

For an excellent example of how to handle HTML at browser level
(hahahah!) quality, check out HTML Tidy (from the W3C). It basically
implemenets the kind of error handling the major browsers do and tries to
generate clean HTML or XHTML. The code is rather readable, and has both a
C and a Java version. It even has modes to help clean up Microsoft
generate "HTML".

Cheers,
Bijan Parsia.



Sat, 17 Jul 2004 22:08:08 GMT  
 Free CL sourcecode to parse HTML, RFC822 headers, etc.?

Quote:


[snip]
> >Note though that although parsing HTML should be a simple application
> >of a generic SGML (not XML, for that you need XHTML) parser, unless
> >you generate the HTML files yourself, it isn't:  There is all kind of
> >{*filter*}out there in the wild, that purports to be HTML (i.e. conforming
> >to some HTML DTD),
> Wrong DTD implies either SGML of XML. HTML is not expressible in
> either.

Huh? Do you mean "HTML files as they are really found in nature"? After
all, not only *can* HTML be modeled by a DTD, it *is* so modeled and
always has been. See the specs.

Syntax only, of course. DTD don't say a thing about semantics.

Quote:
> > and through heroic efforts on the part of the
> >browser writers does render OK.  So unless you can afford to tell 99%
> >percent of your users "Error: This is not HTML!", you'll need to handle
> >all sorts of erroneous stuff, like mis-matched start end end tags,
> >etc.
> Bullshit. None of this is erroneous. From the perspective of
> SGML or XML it is. From the perspective of HTML it is perfectly legal.

No, you're seriously confused. Sorry.

The only thing that determines what's *legal* HTML are the specs. See my
other post for an analysis of this example.

Not that SGML allows for ommitting certain close tags...unlike XML. SGML
is way more permissive.

Quote:
> > Generally parsing real-world HTML is probably akin to heuristic
> >natural language parsing, than it is to SGML parsing.

> If you have an XML parser and not a real HTML parser, then you
> probably would want to go to w3.org . There is a utility there that
> translates from HTML to XHTML.

HTML Tidy, as I mentioned. It also cleans up regular HTML without
converting.

Hmm. Maybe you're confusing a "real" HTML parser with an HTML parser with
excellent error handling? An SGML parser than can read in the HTML DTD (of
whichever version) is as real an HTML parser as you can get. If the HTML
doesn't validate it's not legal SGML *or* HTML (HTML being a SGML
application). That doesn't mean it's not *usable* HTML, or that a browser
should just throw an error.

Cheers,
Bijan Parsia.



Sat, 17 Jul 2004 22:15:53 GMT  
 Free CL sourcecode to parse HTML, RFC822 headers, etc.?

Quote:


> [snip]
>> Note though that although parsing HTML should be a simple application
>> of a generic SGML (not XML, for that you need XHTML) parser, unless
>> you generate the HTML files yourself, it isn't:  There is all kind of
>> {*filter*}out there in the wild, that purports to be HTML (i.e. conforming
>> to some HTML DTD), and through heroic efforts on the part of the
>> browser writers does render OK.

> I think it's a little more complicated. I.e., the standard behavior of
> "ignoring tags you don't understand" (a SGML trope, I believe) conceals a
> multitude of sins, at least for viewing purpose. Plus, the browser parsers
> *introduced* several pervasive bugs (Netscape comment handling, is an
> example, I forget for which versions).

>>  So unless you can afford to tell 99%
>> percent of your users "Error: This is not HTML!", you'll need to handle
>> all sorts of erroneous stuff, like mis-matched start end end tags,
>> etc.  

> Actually, for a fair number of cases, that's not so bad, because of
> implied endtags. E.g.:

>    <li>Bad end tag? </il>
>    <li>No problem!</il>
>    <li> standard sgml will insert a proper "</li>" before the
> erronous one and then ignore the erroneous one.

>>Generally parsing real-world HTML is probably akin to heuristic
>> natural language parsing,

> Not for viewing. For extracting data (screen scraping), sure.

>> than it is to SGML parsing.

> SGML parsing can be kinda {*filter*} :)

> For an excellent example of how to handle HTML at browser level
> (hahahah!) quality, check out HTML Tidy (from the W3C). It basically
> implemenets the kind of error handling the major browsers do and tries to
> generate clean HTML or XHTML. The code is rather readable, and has both a
> C and a Java version. It even has modes to help clean up Microsoft
> generate "HTML".

  ^^^^^^^^
Surely you mean *de*generate here :)

Quote:
> Cheers,
> Bijan Parsia.

--

backronym for Linux:                    \ / No HTML or RTF in mail
        Linux Is Not Unix                        X  No MS-Word in mail
Meme plague ;)   --------->          / \ Respect Open Standards


Wed, 21 Jul 2004 10:12:58 GMT  
 Free CL sourcecode to parse HTML, RFC822 headers, etc.?

Quote:

> Does anybody know of any public-domain or other freely
> available Common-LISP sourcecode for parsing HTML files into
> a structured form, for example <bold>text</bold> should
> parse as something like (bold "text") instead of as
> (start-bold)"text"(end-bold), and <a href="url">text</a>
> should parse as something like (href "url" "text") instead
> of as (start-href "url") "text" (end-href) likewise all
> other semantically nested meaning should be represented as
> nested s-expressions rather than sequences of start and end
> forms as the original HTML shows?

Check out Franz' open source HTML parser, at
<http://opensource.franz.com/xmlutils/index.html>.  It does at least
try to handle some illegal HTML.

John Wiseman



Wed, 28 Jul 2004 12:53:15 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. HTML header parsing

2. rfc822 module: deleting headers

3. import rfc822 # email headers and such

4. rfc822 date header

5. How can I parsing RFC822 message...

6. patch for rfc822.py date parsing

7. rfc822 address parsing

8. ||| COMPACT SOURCECODE PRINTOUT IN WINDOWS - TRY IT FOR FREE |||

9. ||| COMPACT SOURCECODE PRINTOUT IN WINDOWS - TRY IT FOR FREE |||

10. ||| COMPACT SOURCECODE PRINTOUT IN WINDOWS - TRY IT FOR FREE |||

11. newbie: parsing SMTP headers

12. i got it: awk & parse SMTP Headers

 

 
Powered by phpBB® Forum Software