You could also use XWiki's rendering engine (http://rendering.xwiki.org). Here's an example of how you'd parse some mediawiki content:
// Initialize Rendering components and allow getting instances
EmbeddableComponentManager componentManager = new EmbeddableComponentManager();
componentManager.initialize(this.getClass().getClassLoader());
// Get the MediaWiki Parser
Parser parser = componentManager.getInstance(Parser.class, "mediawiki/1.0);
// Parse the content in mediawiki markup and generate an AST (it's also possible to use a streaming parser for large content)
XDOM xdom = parser.parse(new StringReader("... input here"));
// Perform any transformation you wish to the XDOM here
...
// Generate XHTML out of the modified XDOM
WikiPrinter printer = new DefaultWikiPrinter();
BlockRenderer renderer = componentManager.getInstance(BlockRenderer.class, "xhtml/1.0");
renderer.render(xdom, printer);
// The result is now in the printer object
printer.toString();
See more examples at http://rendering.xwiki.org/xwiki/bin/view/Main/GettingStarted
Hope it helps.