Deprecated: Assigning the return value of new by reference is deprecated in /var/www/virtual/geshi.org/htdocs/wiki/inc/parser/xhtml.php on line 943
Table of Contents

The GeSHiXMLRenderer Class

The GeSHiXMLRenderer class is exactly what the name implies; a renderer. There’s more to it too, it renders into XML.

The reason I made the class, was part to have fun, part to show Nigel I could code ;), and part to make GeSHi avalible as a web service. That’s right, a web service. Now, you might think “OMG! WTF is the point of a web service when u can dl GeSHi and use in on ur ws” or something like that. And, believe me, you’re absolutely right, you can download GeSHi. But it is a php script. That means it can only run on php. The idea of a web service is that other scripts, which can be written in any language (ASP, Perl, Python, php), can make a GeSHi highlight via XML.

GeSHi is a resource hog

GeSHi is a really great script, believe me. But it has a few drawbacks, one of them being that it is a resource hog. It draws a lot of resources. Part because of the modulairty, part because of the large classes, and part because it is not optimized yet. A few ways to solve this:

  • Buy a better server. This is maybe the easiest solution, but costs money.
  • Memcaching. Because of the large objects, memcaching might help. A few tools are Memcached and Turck MMCache.
  • Script optimizer. This caches the scripts in compiled form. A few are Zend Optimizer, and APC.
  • Buy another server. That’s right, two servers work together. Here is where the XML renderer comes in.

If you put the XML renderer to run on one machine, connected to another via high-speed LAN. The other machine can do XML requests from GeSHi, thereby lightening the load.

*Example coming*

XML File Syntax

The syntax of the XML file, as described in the geshixml.dtd, is as follows:

<?xml version=”1.0”?> <!– This is needed. It makes sure the document is parsed as XML. –>
<!DOCTYPE GESHIXML SYSTEM “URL_TO_DTD“> <!– The doctype. This loads the DTD file into the document. –>


<geshi language=”the_lang” [theme=”the_theme”]> <!– Root element. language is the language of the code, theme is the theme to be used. (optional) – >

[<css [type=”text/css” [version=”2.0”]]>] <!– Global CSS. This is things like classes. Optional (all). –>

<![CDATA[CSS]]> <!– CSS is wrapped in CDATA. – >

[</css>] <!– CSS end. – >

<token type=”context_name” [url=”http://gh00gle.com” [css=”the_css”]]> <!– Token element. Type is the token context name (required). URL is htere if there is a link, css is the css of the token. (both optional) – >

<![CDATA[the_token]]> <!– The token itself. It is wrapped in <![CDATA[ ]]> to prevent any < and >s in the code to be parsed. – >

</token> <!– End token element. – >

</geshi> <!– End geshi element. – >

That is the syntax, fastly described. Things in [] are optional (except the CDATA, which is not.)

Cheers!


Knut A. Wikström 2006/12/31 05:47

 
renderer/xml.txt · Last modified: 2011/09/01 13:03
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki