Writing to KHTMLPart and stylesheets

Michael Leupold lemma at confuego.org
Wed Aug 5 13:19:03 BST 2009


Michael Leupold wrote:
> Maksim Orlovich wrote:
>> On Tuesday 04 August 2009 20:01:24 Michael Leupold wrote:
>>> If there's currently no document loaded or if the currently loaded
>>> document is a html document (no matter if it has an <?xml?> header or
>>> not), the output is displayed properly.
>>> However if the current document is an xml document of unknown type it
>>> displays a parsing error (as the new content is not proper xml because
>>> meta misses the ending tag).
>>>
>>> Is there any way I could work around this?
>> 
>> You can set the mimetype you want via KParts' arguments:
>> KParts::OpenUrlArguments args = part->arguments();
>> args.setMimeType("foo/bar");
>> part->setArguments(args);
> 
> Awesome. Works fine.

Is args.setMimeType(""); part->setArguments(args); legal? It seems this will 
work for xslt generating html as well as xhtml. If it isn't I'll have to 
find a yet to determine the proper mimetype yet.

>>> Apart from that I've also been failing to get the attributes of an
>>> embedded <?xml-stylesheet?> with type "text/xsl" using part->document()-
>>>
>>> >styleSheets(). It seems this only gives me css stylesheets. Is this
>>>
>>> assumption correct and the behaviour intended?
>> 
>> Yeah. Look for a PROCESSING_INSTRUCTION_NODE child of the document, and
>> go from there. (Hmm, maybe we should export
>> traverseNextChild/traversePrevChild in public API)?
> 
> Alright, I'll try that tomorrow. For the moment I was using libxml's XPath
> but the code turned out pretty weird because I put the contents back into
> a QString for parsing.

Works as well and turned out to be simpler than the XPath stuff.

Regards,
Michael






More information about the kfm-devel mailing list