-2

Trying to work this demo from xwiki in java standalone class, not working. I am using xwiki 7.0 version. Anyone tried this out?

http://rendering.xwiki.org/xwiki/bin/view/Main/Demo?inputsyntax=xhtml%2F1.0&outputsyntax=xwiki%2F2.1&input=%3Ch3+id%3D%22Hhelo%22%3E%3Cspan%3Ehelo%3C%2Fspan%3E%3C%2Fh3%3E#HDemo

public class HtmlToXwikiTest
{
    private Converter converter;
private WikiPrinter printer;

@Test
public void testHtmlToMarkdown() throws ComponentLookupException, ConversionException, ParseException, ComponentRepositoryException
{
    WikiPrinter printer = new DefaultWikiPrinter();
    converter.convert(new StringReader("<h3 id=\"HHeader3\"><span>Header 3</span></h3>"), Syntax.XHTML_1_0, Syntax.XWIKI_2_1,  printer);

    System.out.println(printer.toString());
    assertThat(printer.toString(), containsString("==="));
}

@Before
public void setUp() throws ComponentLookupException, ConversionException
{
    EmbeddableComponentManager componentManager = new EmbeddableComponentManager();
    componentManager.initialize(this.getClass().getClassLoader());

    converter = componentManager.getInstance(Converter.class);
    printer = new DefaultWikiPrinter();
}

}

Getting, java.lang.NoSuchFieldError: fRecognizedFeatures at org.apache.xerces.parsers.XML11NonValidatingConfiguration.(Unknown Source) at org.apache.xerces.parsers.XML11NonValidatingConfiguration.(Unknown Source) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:379) at org.xwiki.xml.internal.DefaultXMLReaderFactory.createXMLReader(DefaultXMLReaderFactory.java:74) at org.xwiki.rendering.internal.parser.xhtml.wikimodel.XWikiXMLReaderFactory.createXMLReader(XWikiXMLReaderFactory.java:73) at org.xwiki.rendering.internal.parser.xhtml.XHTMLParser.createWikiModelParser(XHTMLParser.java:151) at org.xwiki.rendering.internal.parser.wikimodel.AbstractWikiModelParser.parse(AbstractWikiModelParser.java:128)

Jon Smith
  • 155
  • 1
  • 3
  • 7

1 Answers1

0

Your example looks ok (even though you're defining the printer object twice but that's not a problem for the test).

At DefaultXMLReaderFactory.java:74, the code is:

// See http://xerces.apache.org/xerces2-j/faq-grammars.html#faq-1
Object xercesConfiguration = Class.forName("org.apache.xerces.parsers.XML11NonValidatingConfiguration").newInstance();

From your stack trace the XML11NonValidatingConfiguration class could be loaded but it's the constructor call that is failing somehow. Seen the error about fRecognizedFeatures I don't see how that's possible...

If I were you I'd try to use a different version of Xerces to see if it helps.