Code example for DOMImplementation

Methods: createDocument

0
  @Before 
  public void setUp() { 
    Injector injector = Guice.createInjector(new ParseModule(), new PropertiesModule());
    parser = injector.getInstance(GadgetHtmlParser.class);
    domImpl = injector.getInstance(DOMImplementation.class);
    doc = domImpl.createDocument(null, null, null);
    converter = new Converter(parser, domImpl);
  } 
   
  @Test 
  public void convertSingleElement() throws Exception { 
    String xml = "<os:elem id=\"id\" foo=\"bar\">String value</os:elem>";
    assertEquals( 
        new JSONObject("{n:\"template\",a:[],c:[{n:\"os:elem\",a:[{n:\"foo\",v:\"bar\"}," +
            "{n:\"id\",v:\"id\"}],c:[\"String value\"]}]}").toString(),
        converter.domToJson(xml));
  } 
   
  @Test 
  public void convertMixedTreeWithIgnorables() throws Exception { 
    String xml = "<b>Some ${viewer} content</b>  <img/><!-- comment --><os:Html/>";