SrgsNodeFactory implements XmlNodeFactory<SrgsNode> { public SrgsNode getXmlNode(final Node node) { if (node == null) { return null; } if (node instanceof SrgsNode) { return (SrgsNode) node; } String name = node.getLocalName(); if (name == null) { name = node.getNodeName(); } final SrgsNode srgsXmlNode = NODES.get(name); if (srgsXmlNode == null) { LOGGER.warning("cannot resolve node with name '" + name + "'"); return new GenericSrgsNode(node); } return (SrgsNode) srgsXmlNode.newInstance(node, this); } SrgsNodeFactory(); SrgsNode getXmlNode(final Node node);  }
@Test public void testGetXmlNode() throws Exception { final SrgsXmlDocument document = new SrgsXmlDocument(); final Grammar grammar = document.getGrammar(); grammar.setRoot("test"); final Rule rule = grammar.appendChild(Rule.class); rule.setId("test"); rule.addText("this is a test"); final SrgsNodeFactory factory = new SrgsNodeFactory(); final SrgsNode node = factory.getXmlNode(rule); Assert.assertNotNull(node); Assert.assertEquals(Rule.TAG_NAME, node.getTagName()); }