Package cn.org.rapid_framework.generator.util.XMLHelper

Examples of cn.org.rapid_framework.generator.util.XMLHelper.NodeData


public class XMLHelperTest extends TestCase {
   
    public void test_blog() throws FileNotFoundException, SAXException, IOException {
       
        File file = FileHelper.getFileByClassLoader("XMLHelper_test.xml");
        NodeData nd = new XMLHelper().parseXML(new FileInputStream(file));
       
        Map table = nd.attributes;
        List<NodeData> columns = nd.childs;
        assertEquals("table_name",nd.nodeName);
        assertEquals("cn1",table.get("className"));
View Full Code Here


        System.out.println(table);
        System.out.println(columns);
    }

    public void test_parseXML_by_innerXML() throws SAXException, IOException {
        NodeData nd = parseXML("<?xml version='1.0' encoding='UTF-8'?> <root><!--comment--><name age='123'>bad&gt;&lt;</name><sex>F<!--123--></sex><alias><![CDATA[&gt;=123<>]]></alias><include refid='123'/></root>");
        assertEquals("bad>&lt;",nd.childs.get(0).innerXML);
        assertEquals("F",nd.childs.get(1).innerXML);
        assertEquals("<![CDATA[&gt;=123<>]]>",nd.childs.get(2).innerXML);
        assertEquals("<include refid=\"123\"/>",nd.childs.get(3).outerXML);
//        assertEquals("<root><name age='123'>bad</name><sex>F</sex><alias><![CDATA[&gt;=123<>]]></alias></root>",nd.innerXML);
View Full Code Here

//      assertEquals("<!--comment--><name age='123'>bad</name><sex>F</sex>",nd.innerText);
//      assertEquals("<root><!--comment--><name age='123'>bad</name><sex>F</sex></root>",nd.outerText);
    }

    public void test_parseXML_by_innerXML_escape() throws SAXException, IOException {
        NodeData nd = parseXML("<?xml version='1.0' encoding='UTF-8'?> <root><!--comment--><name age='&apos;&quot;123&gt;&lt;&amp;'>bad&gt;&lt;&apos;&quot;123&gt;&lt;&amp;</name><sex>F<!--123--></sex><alias><![CDATA[&gt;=123<>]]></alias><include refid='123'/></root>");
        assertEquals("<name age=\"'&quot;123>&lt;&amp;\">bad>&lt;'\"123>&lt;&amp;</name>",nd.childs.get(0).outerXML);
        assertEquals("F",nd.childs.get(1).innerXML);
        assertEquals("<![CDATA[&gt;=123<>]]>",nd.childs.get(2).innerXML);
        assertEquals("<include refid=\"123\"/>",nd.childs.get(3).outerXML);
    }
View Full Code Here

        assertEquals("<![CDATA[&gt;=123<>]]>",nd.childs.get(2).innerXML);
        assertEquals("<include refid=\"123\"/>",nd.childs.get(3).outerXML);
    }
   
    public void test_get_NodeData() throws SAXException, IOException {
      NodeData nd = parseXML("<?xml version='1.0' encoding='UTF-8'?> <root><!--comment--><name age='123'>bad</name><sex>F</sex></root>");
      assertEquals("badF",nd.nodeValue);
      assertEquals("bad",nd.childs.get(0).nodeValue);
      assertEquals("F",nd.childs.get(1).nodeValue);
     
     
View Full Code Here

//      assertEquals("<root><!--comment--><name age='123'>bad</name><sex>F</sex></root>",nd.outerText);
     
    }

    public void test_parseXML_by_cdata() throws SAXException, IOException {
    NodeData nd = parseXML("<?xml version='1.0' encoding='UTF-8'?> <root><!--comment--><name age='123'>bad</name><sex>F<!--123--></sex><alias><![CDATA[&gt;=123<>]]></alias></root>");
    assertEquals("bad",nd.childs.get(0).nodeValue);
    assertEquals("F",nd.childs.get(1).nodeValue);
    assertEquals("&gt;=123<>",nd.childs.get(2).nodeValue);
      assertEquals("<root><name age=\"123\">bad</name><sex>F</sex><alias><![CDATA[&gt;=123<>]]></alias></root>",nd.outerXML);
      assertEquals("<name age=\"123\">bad</name><sex>F</sex><alias><![CDATA[&gt;=123<>]]></alias>",nd.innerXML);
View Full Code Here

//      assertEquals("<!--comment--><name age='123'>bad</name><sex>F</sex>",nd.innerText);
//      assertEquals("<root><!--comment--><name age='123'>bad</name><sex>F</sex></root>",nd.outerText);
  }

    public void test_parseXML_by_nodevalue() throws SAXException, IOException {
    NodeData nd = parseXML("<?xml version='1.0' encoding='UTF-8'?> <root>AAA<!--comment-->BBB<name age='123'>bad</name><sex>F<!--123--></sex><alias><![CDATA[&gt;=123<>]]></alias>CCC</root>");
    assertEquals("AAABBBbadF&gt;=123<>CCC",nd.nodeValue);
    assertEquals("bad",nd.childs.get(0).nodeValue);
    assertEquals("F",nd.childs.get(1).nodeValue);
    assertEquals("&gt;=123<>",nd.childs.get(2).nodeValue);
   
View Full Code Here

 
  /** 得到表的自定义配置信息 */
  public static class TableOverrideValuesProvider {
   
    private static Map getTableConfigValues(String tableSqlName){
      NodeData nd = getTableConfigXmlNodeData(tableSqlName);
      if(nd == null) {
          return new HashMap();
      }
      return nd == null ? new HashMap() : nd.attributes;
    }
View Full Code Here

      }
      return nd == null ? new HashMap() : nd.attributes;
    }
 
    private static Map getColumnConfigValues(Table table, Column column) {
      NodeData root = getTableConfigXmlNodeData(table.getSqlName());
      if(root != null){
         for(NodeData item : root.childs) {
           if(item.nodeName.equals("column")) {
               if(column.getSqlName().equalsIgnoreCase(item.attributes.get("sqlName"))) {
                   return item.attributes;
View Full Code Here

      }
      return new HashMap();
    }
   
    private static NodeData getTableConfigXmlNodeData(String tableSqlName){
      NodeData nd = getTableConfigXmlNodeData0(tableSqlName);
      if(nd == null) {
        nd = getTableConfigXmlNodeData0(tableSqlName.toLowerCase());
        if(nd == null) {
          nd = getTableConfigXmlNodeData0(tableSqlName.toUpperCase());
        }
View Full Code Here

      IOHelper.close(in, null);
    }
  }
 
    public TableConfig parseFromXML(InputStream inputStream) throws SAXException, IOException {
        NodeData nodeData = new XMLHelper().parseXML(inputStream);
        TableConfig config = new TableConfig();
       
        // table
        BeanHelper.copyProperties(config, nodeData.attributes,true);
       
View Full Code Here

TOP

Related Classes of cn.org.rapid_framework.generator.util.XMLHelper.NodeData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.