On Jun 22, 2009, at 8:40 PM, cristinas (SVN) wrote:
Author: cristinas
Date: 2009-06-22 20:40:42 +0200 (Mon, 22 Jun 2009)
New Revision: 21427
Modified:
sandbox/gsoc/xoo/pom.xml
sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/XOO.java
sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/
XWikiExtensionActions.java
sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/xwikilib/converter/
internal/DefaultBidirectionalConverter.java
Log:
exception solved
[snip]
-public class DefaultBidirectionalConverter implements
BidirectionalConverter
+public class DefaultBidirectionalConverter implements
BidirectionalConverter, Initializable
{
- public static final Syntax XHTML_SYNTAX = new
Syntax(SyntaxType.XHTML, "1.0");
-
- public static final Syntax XWIKI_20 = new
Syntax(SyntaxType.XWIKI, "2.0");
-
public String fromXHTML(String html)
{
// TODO Auto-generated method stub
@@ -54,18 +60,21 @@
{
try {
+ EmbeddableComponentManager ecm = new
EmbeddableComponentManager();
+ ecm.initialize(this.getClass().getClassLoader());
The CM should be be instantiated only once when the app initializes IMO.
Thanks
-Vincent
+
// Parse
- Parser parser = new WikiModelXWikiParser();
+ Parser parser = ecm.lookup(Parser.class,
Syntax.XWIKI_2_0.toIdString());
XDOM dom = parser.parse(new StringReader(source));
// Execute transformations
- TransformationManager txManager = new
DefaultTransformationManager();
- txManager.performTransformations(dom, XWIKI_20);
+ TransformationManager txManager =
(TransformationManager) ecm.lookup(TransformationManager.class);
+ txManager.performTransformations(dom,
parser.getSyntax());
// Render
- WikiPrinter printer = new DefaultWikiPrinter();
- PrintRendererFactory factory = new
DefaultPrintRendererFactory();
- PrintRenderer renderer =
factory.createRenderer(XHTML_SYNTAX, printer);
+ DefaultWikiPrinter printer = new DefaultWikiPrinter();
+ PrintRendererFactory factory =
ecm.lookup(PrintRendererFactory.class);
+ Renderer renderer =
factory.createRenderer(Syntax.XHTML_1_0, printer);
dom.traverse(renderer);
return printer.toString();
@@ -76,4 +85,10 @@
}
+ public void initialize() throws InitializationException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}