Re: Processing HTML document.
On Wed, Jun 05, 2002 at 10:41:11AM +0200, Antonio Fiol wrote: > Daniel Veillard wrote: > > A slightly different approach is to use an HTML parser front-end > >instead of an XML one for the XSLT processor, that's how I maintain > >a number of web pages (authoring HTML is easier for me than maintaining > >X(HT)ML). With xsltproc the --html option does this, and I'm pretty sure > >most Java based implementation can use an HTML parser delivering SAX > >events (but I never tried). > > > >Daniel > > > > > > > To give you a complete approach of what I am doing: > > - I am creating a Servlet based interface to some data. For that, I > created a servlet that detects the user agent, and sends it either XML > (if we are certain the browser supports XSLT) or HTML, by transforming > the XML with a XSLT stylesheet on the server. > > - My XSLT code should create a whole HTML page, for whose many elements > are constant, and the "template" (not in the XSLT sense) for the page is > defined (in HTML) by our webmaster. I can ask him to write XHTML, and/or > run HTML TIDY on that code to get proper XHTML. However, I need to > transform that into an XSLT file. I use an XSLT file called > "htmltoxsl.xsl" I created for that purpose. > > - My htmltoxsl.xsl reads a "slightly modified (<?xml...?> added at the > beginning, xsl:apply-templates elements added)" (X)HTML page and outputs > an XSLT stylesheet containing some IMPORT tags, the HTML code (which > contains some xsl:apply-templates inside) inside an <xsl:when test="(no > error node is present on the XML file)"> in the template for "/". > > - I would like, but I cannot: > * Ask our webmaster to write XSLT. > * Include the <?...?> at the beginning of the file and ask our webmaster > to edit that (DreamWeaver does not support it). > * Use HTML Tidy on files containing xsl:apply-templates with optional > xsl:with-param. HTML Tidy does not understand them correctly, even > adding the tags to the list of supported tags. > > > I am partially happy about what I managed to get (the described > procedure), but if someone has suggestions on better procedures, do not > hesitate to tell me. Hum, not sure I fully understood all the steps and limitations, but it sounds that some part of that process might be automated or simplified with XInclude preprocessing within the XSL stylesheets to grab the parts of the (X)HTML template. Just a suggestion... Daniel -- Daniel Veillard | Red Hat Network http://redhat.com/products/network/ veillard@xxxxxxxxxx | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format