W3C home > Mailing lists > Public > html-tidy@w3.org > January to March 2010

Re: Tidy parsing with SAX-like callbacks, and node replacement

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Fri, 15 Jan 2010 22:23:04 +0100
To: John Kemp <john@jkemp.net>
Cc: html-tidy@w3.org
Message-ID: <3qm1l5t5a348d02oma4ub4f0mj4up1fa07@hive.bjoern.hoehrmann.de>
* John Kemp wrote:
>As far as I can tell, tidylib doesn't provide any callback interface so
>that I could tell when a particular element has been parsed (a la SAX),
>and there is no ability for me to replace a node, or set of nodes in the
>parsed tree. Have I got that right? Are there any plans to offer such an
>interface? 

There is no callback interface as the document structure of what has
been seen may change much later, e.g. when a <title> element inside the
<body> element is moved into the <head> element. The tree is also read-
only as far as the public interface is concerned. There are no plans to
change either. The usual approach is to traverse the built tree and map
it to whatever suits you, e.g. you could traverse it and generate SAX
events from the nodes in it. If you would like to use the pretty printer
after you have made modifications (in your own model), you can serialize
the document and pass it back to Tidy.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
Received on Friday, 15 January 2010 21:23:27 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:14:00 GMT