[Mediawiki-l] Checking or extracting contents of custom XML tag before saving

Flip Mozart flipmozart at yahoo.com
Tue Jul 24 09:59:00 UTC 2007


Hello all!

I'm writing a custom tag (I call it <xdata>) that looks like this:

   ------------------------------------------------------------------
   Article Name: Country:US

   The US has a population of <xdata id="US_Population">280,000,000</xdata>.
   ------------------------------------------------------------------

I would like to check or extract the contents of this custom XML tag before saving it. Is there any convenient way to extract the following information:

   1) id attribute (e.g. "US_Population" in the above example) in the opening tag
   2) the value in between the opening and closing tags (e.g. 280,000,000 in the above example).

I noticed that the $wgParser->setHook( 'xdata', 'some_function') can extract extract attributes like "id" and store it in a variable $argv.

For example, I have written the ff. code to correctly parse the custom tag BEFORE DISPLAYING it:

function wfXdataExtension() 
   {
   global $wgParser;
   $wgParser->setHook( "xdata", "renderXdata" );
   }

function renderXdata( $input, $argv, &$parser ) 
   {    
   // some code that uses contents of $argv 
   }

I am looking for a way to parse the custom tag BEFORE SAVING an article that contains it.

Thank you very much!

Filip

 Send instant messages to your online friends http://uk.messenger.yahoo.com 


More information about the MediaWiki-l mailing list