Re: Parsing HTML
Richard Kunze <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.xmlc |
|---|---|
| Organization | Tivano Software GmbH |
| Message-ID | <[email protected]> |
On Wednesday 26 March 2003 18:33, Ben Sinclair wrote: > Is there good documentation on how to do [ automatic reloading > of *ML pages ]? Sorry, there's not much documentation at the site yet, I didn't get around to document the new features. Maybe you want to write a howto based on your experiences? Anyway, here's the basiscs that should get you going: Prerequisites: - Use XMLC 2.2. Either from CVS, or the binary package provided by David Li - When you initally compile the pages, pass the "-for-deferred-parsing" option to XMLC For the following, I'm assuming that you use XMLC in a servlet environment. In this case, the XMLC factory settings are controlled by servlet context parameters specified in web.xml. A detailed list of the availalbe parameters is included in the javadocs for org.enhydra.xml.xmlc.servlet.XMLCContext. Here are the most important ones pertaining to auto reloading: - xmlcReloading: Must have the value "reparse" to enable on-the-fly reparsing - xmlcReparseResourceDirs: A list of directories that XMLC uses to find HTML files. Set this to your HTML document root (or document roots, you can specify a path here - XMLC will use the first matching file it finds on this path) Let's assume you store your HTML pages in "/my/document/root", and you've got a page named "myPage.html". You've compiled the page with XMLC for deferred parsing which gave you the XMLC class "myPageHTML", and you've put a context parameter entry in web.xml that sets the reparse resource dir to "/my/document/root". Here's what you need do in the servlet doGet() method in order to access the page: // Get the XMLC context. "this" is the servlet. XMLCContext ctx = XMLCContext.getContext(this); // Get the XMLC factory from the context XMLCFactory factory = ctx.getXMLCFactory(); // Get the page MyPageHTML page = (MyPageHTML)factory.create(MyPageHTML.class); The factory automatically takes care of reparsing the HTML every time that either "/my/document/root/myPage.html" or "/my/document/root/mypage.xmlc" is changed. Changes are detected by checking the last modified timestamp of the files against the time of the last reparse, so you can force a reparse simply by touching the file. Hope this helps, Richard -- Richard Kunze [ t]ivano Software, Bahnhofstr. 18, 63263 Neu-Isenburg Tel.: +49 6102 80 99 07 - 0, Fax.: +49 6102 80 99 07 - 1 http://www.tivano.de, [email protected]
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQA+gfG886Aqb3OZfF4RAglJAJ9VdFwsrKtwxzWC2UlgSnffzLeGJQCfbDkK r7mdwIR7+7pTIcE0vOo+D14= =7AeD -----END PGP SIGNATURE-----