1 package net.sourceforge.phpeclipse.wizards.xml;
3 import org.w3c.dom.Element;
4 import org.w3c.dom.NamedNodeMap;
5 import org.w3c.dom.Node;
6 import org.w3c.dom.NodeList;
7 import org.w3c.dom.Text;
9 import com.quantum.util.StringMatrix;
11 public class ModelUtil {
13 public static String getTableName(Element root) {
14 NodeList columns = root.getElementsByTagName("table");
15 for (int i = 0; i < columns.getLength(); i++) {
16 Node column = columns.item(i);
17 String header = column.getNodeName();
18 if (header.equals("table")) {
19 NamedNodeMap map = column.getAttributes();
20 Node name = map.getNamedItem("name");
24 return name.getNodeValue();
31 public static void xmlToStringMatrix(StringMatrix matrix, Element root, String sub) {
32 NodeList columns = root.getElementsByTagName(sub);
33 for (int i = 0; i < columns.getLength(); i++) {
34 Node column = columns.item(i);
35 NodeList columnList = column.getChildNodes();
36 for (int j = 0; j < columnList.getLength(); j++) {
37 Node node = columnList.item(j);
38 String header = node.getNodeName();
39 if (header.equals("#text")) //$NON-NLS-1$
42 if (node != null && node.hasChildNodes()) {
43 Node valueNode = node.getFirstChild();
44 if (valueNode instanceof Text) {
45 value = valueNode.getNodeValue();
48 if (!matrix.contains(header))
49 matrix.addHeader(header);
50 matrix.addAt(header, value, i);