Re: [xslt] Reading HTML documents using the document() function



Hi Daniel,

Daniel Veillard wrote:

>   Hum, no, there is no such extension at the moment. It seems the best
> way would be to define an extension function in the libxslt namespace:
>     "http://xmlsoft.org/XSLT/namespace";
> like document() but called htmldocument() and using the HTML parser.

Yes. In the meantime; for pythoners, this quick and dirty hack seems to 
be working fine (assuming that href is a string):

  def htmldocument(ctx, href):
  	global doc
  	parent = doc.newDocNode(None, 'p', None)
  	newdoc = libxml2.htmlParseFile(href, None)
  	parent.addChild(newdoc.getRootElement())
  	return [parent]

> Does any other XSLT parser provide something similar, it would be best
> to try to reuse the same names if possible.

Not that I am aware of. Most of the XSLT processors rely on SAX/DOM 
parsers which can only read well formed XML...

Thanks,

Eric

> 
> Daniel
> 

-- 
See you in San Diego.
                                http://conferences.oreillynet.com/os2002/
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
http://xsltunit.org      http://4xt.org           http://examplotron.org
------------------------------------------------------------------------




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]