DefaultWmeToXml { public Document toXml(Identifier root, String rootName) { final Document doc = builder.getDOMImplementation().createDocument(null, rootName, null); toXml(root, doc.getDocumentElement()); return doc; }  Document toXml(Identifier root, String rootName); Element toXml(Identifier root, Element element); static final String ATTRS; static final String TEXT; static final String NEXT; }
@Test public void testToXml() throws Exception { final Agent agent = new Agent(); agent.getProductions().loadProduction( "testToXmlInit (state <s> ^superstate nil ^io.input-link <il>) -->" + "(<il> ^location <loc> ^person <person>)" + "(<loc> ^/attrs <attrs> ^/text |This is some text|)" + "(<attrs> ^name |Ann Arbor| ^population 100000)" + "(<person> ^name Bill ^where <loc>)"); final AtomicReference<String> result = new AtomicReference<String>(); agent.getRhsFunctions().registerHandler(new StandaloneRhsFunctionHandler("finish") { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { result.set(arguments.get(0).toString()); return null; }}); agent.getProductions().loadProduction( "testToXml (state <s> ^superstate nil ^io.input-link <il>) (<il> ^location <loc>) -->" + "(finish (to-xml --root something <il>))"); agent.runFor(1, RunType.DECISIONS); assertNotNull(result.get()); assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<something>" + "<location name=\"Ann Arbor\" population=\"100000\">This is some text</location>" + "<person>" + "<name>Bill</name>" + "<where>L1</where>" + "</person>" + "</something>", result.get()); }