Hi Arun,
You should definitely not use this script.
Your first task if you haven't done it yet should be to understand the
XWiki Rendering module.
See
Hi,
I have a small doubt on how listener is implemented in
MediaWiki2XWikiExtension
Groovy Code Snippet --
http://code.xwiki.org/xwiki/bin/view/Extensions/MediaWiki2XWikiExtension
<%
import org.dom4j.io.SAXReader
import org.dom4j.*
import groovy.net.xmlrpc.*
import java.net.ServerSocket
import org.wikimodel.wem.mediawiki.MediaWikiParser
import org.wikimodel.wem.xwiki.*
class PruningPageHandler implements ElementHandler {
def proxy, token;
def counter = 0;
def max = 10000;
PruningPageHandler(proxy, token) {
this.proxy = proxy
this.token = token
}
def messages = []
public void onStart(ElementPath path) { }
public void onEnd(ElementPath path) {
def page = path.current
def title = page.elementText('title')
title = title.replaceAll(' ','_')
def id = page.elementText('id')
println(title+ '('+counter+')')
def revision = page.element('revision')
def revid = revision.elementText('id');
def revtext = revision.elementText('text');
def contributor = revision.element('contributor')
def username = contributor.elementText('username')
def index = revtext.substring(0,
Math.min(30,revtext.length())).toLowerCase().indexOf("redirect")
counter++;
if (counter < max && index < 0) {
revtext = revtext.replaceFirst("^-", "*");
revtext = revtext.replaceAll("__","")
revtext = revtext.replaceAll("[\\|][\\+]","")
def buffer = new StringBuffer()
buffer.append(revtext)
try {
*def reader = new StringReader(revtext);
def parser = new MediaWikiParser();
buffer = new StringBuffer()
def listener = new XWikiSerializer(buffer);
parser.parse(reader, listener);*
} catch (Exception e) {
println(e.getMessage())
}
def map = new HashMap()
map.put('content', buffer.toString())
map.put('modifier', username)
map.put('space','Wikipedia')
map.put('title',title)
try {
proxy.confluence1.storePage(token, map)
} catch (Exception e) {
println(e.getMessage())
}
}
page.detach() // prune the tree
}
}
%>
XWikiSerializer has a constructor with some class implementing
IWikiPrinter
. But how come a StringBuffer is used here.
Am trying to simulate the same from a java application,and a fact
that use
of StringBuffer fails here. How to create a listener object in that
case.
Thanks and Best Regards,
Arun Reddy
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs