source: trunk/greenstone3-extensions/gs3build/src/org/greenstone/gsdl3/gs3build/schema/Schema.java@ 12188

Last change on this file since 12188 was 12188, checked in by kjdon, 18 years ago

Initial revision

  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1package org.greenstone.gsdl3.gs3build.schema;
2
3import org.w3c.dom.Element;
4import org.w3c.dom.Node;
5import org.w3c.dom.NodeList;
6
7import java.util.List;
8import java.util.ArrayList;
9
10public class Schema
11{
12 List children;
13
14 public Schema(Node node)
15 {
16 this.children = new ArrayList();
17
18 NodeList elements = node.getChildNodes();
19
20 System.out.println("Schema has " + elements.getLength() + " children");
21 for (int e = 0; e < elements.getLength(); e++) {
22 System.out.println("Subcomponent " + e);
23 // TODO: actually test what is being parsed here!
24 if (elements.item(e).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE) {
25 continue;
26 }
27
28 System.out.println(elements.item(e));
29
30 Element element = (Element) elements.item(e);
31
32 String elementName = element.getLocalName();
33 String fullName = element.getNodeName();
34 String valueName = element.getNodeValue();
35
36 System.out.println(elementName + " " + fullName + " " + valueName);
37
38 if (elementName == null) {
39 elementName = fullName;
40 }
41
42 System.out.println(elementName);
43 elementName = SchemaNode.getElementName(elementName);
44
45 if (elementName.equals("element")) {
46
47 SchemaElement thisElement = new SchemaElement(element);
48/*
49 NodeList attributes = element.getElementsByTagName("attribute");
50
51 for (int i = 0; i < attributes.getLength(); i++) {
52 Element attribute = (Element) attributes.item(i);
53 // handle that attribute, create its node and check what you get out
54 try {
55 SchemaAttribute thisAttribute = new SchemaAttribute(attribute);
56 thisElement.addAttribute(thisAttribute);
57 }
58 catch (SchemaException ex) {
59 // do nothing at the moment - though a malformed attribute should be
60 // cause for throwing everything in the air
61 }
62 }*/
63 this.children.add(thisElement);
64 }
65 else {
66 try {
67 Object child = SchemaNodeFactory.makeNode(element);
68 if (child != null) {
69 this.children.add(child);
70 }
71 }
72 catch (SchemaException metaEx)
73 {
74 }
75 }
76 }
77 }
78}
Note: See TracBrowser for help on using the repository browser.