MacroTransformationContext is very macro oriented, most of its work is
about finding the right syntax to parse the syntax. If you are not in
a macro and you know the syntax of the content you want to parse you
should directly use a parser.

See 
http://rendering.xwiki.org/xwiki/bin/view/Main/GettingStarted#HModifyallLinkstobedisplayedinitalics
for an example of code getting and using a parser to get an XDOM from
a string content.

2012/4/1 Grüner Heinrich <[email protected]>:
> Hi,
> I want to parse XWiki Syntax in a independent thread (not via xwiki default
> transformation workflow).
> how is it possible to intantiate a valid MacroTransformationContext?
> This Context is needed to call the contentParser.
>
> I tried this:
>            MacroTransformationContext mc=new MacroTransformationContext(new
> TransformationContext());
>            mc.setSyntax(Syntax.XWIKI_2_0);
>           contentParser.parse(ts.getContent(),mc,true,true);
>
> but it threw the following Exception:
>
> org.xwiki.rendering.macro.MacroExecutionException: Failed to parse content [
>  == Werner ==   * test ]
>        at
> org.xwiki.rendering.internal.macro.DefaultMacroContentParser.parseXDOM(DefaultMacroContentParser.java:122)
>        at
> org.xwiki.rendering.internal.macro.DefaultMacroContentParser.parse(DefaultMacroContentParser.java:77)
>        at
> org.centauron.xwiki.XWikiConnector.getCodeSnipsFromPage(XWikiConnector.java:117)
>        at
> org.centauron.xwiki.XWikiConnector.getCodeSnipsFromPage(XWikiConnector.java:105)
> ...
>
> Any suggestions?
>
> Thanks,
> Stefan.
>
> _______________________________________________
> devs mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/devs



-- 
Thomas Mortagne
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to