SoarTechXmlToWme implements XmlToWme { public Identifier fromXml(Element element) { return fromXml(element, null); } SoarTechXmlToWme(WmeFactory<?> wmeFactory); static SoarTechXmlToWme forInput(InputOutput io); static SoarTechXmlToWme forRhsFunction(RhsFunctionContext rhsContext); Identifier fromXml(Element element); Identifier fromXml(Element element, Identifier targetId);  }
@Test public void testFromXml() throws Exception { final Agent agent = new Agent(); agent.getProperties().set(SoarProperties.WAITSNC, true); agent.getProductions().loadProduction( "testFromXml (state <s> ^superstate nil ^io.input-link <il>) -->" + "(<il> ^xml (from-st-xml |" + "<ignored>" + "<location link-id='L1'>" + " <name>Ann Arbor</name>" + " <population type='integer'>100000</population>" + "</location>" + "<person>" + " <name>Bill</name>" + " <where link='L1'/>" + "</person>" + "</ignored>|))"); agent.runFor(1, RunType.DECISIONS); final Identifier il = agent.getInputOutput().getInputLink(); final MatcherBuilder m = Wmes.matcher(agent); final Identifier xml = m.attr("xml").find(il).getValue().asIdentifier(); assertNotNull(xml); final Wme location = m.attr("location").find(xml); assertNotNull(location); assertEquals("Ann Arbor", m.attr("name").find(location).getValue().asString().getValue()); assertEquals(100000, m.attr("population").find(location).getValue().asInteger().getValue()); final Wme person = m.attr("person").find(xml); assertNotNull(person); assertEquals("Bill", m.attr("name").find(person).getValue().asString().getValue()); assertSame(location.getValue(), m.attr("where").find(person).getValue()); }