source: trunk/greenstone3-extensions/gs3build/src/org/greenstone/gsdl3/gs3build/schema/SchemaComplexType.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: 1.5 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 SchemaComplexType implements SchemaType
11{
12 public String name;
13 public List children;
14
15 public SchemaComplexType(Element element) throws SchemaException
16 {
17 this.name = element.getAttribute("name");
18 if (name == null)
19 { throw new SchemaException("Type defined without name");
20 }
21
22 this.children = new ArrayList();
23
24 NodeList childNodes = element.getChildNodes();
25 for (int i = 0; i < childNodes.getLength(); i ++) {
26 Node node = childNodes.item(i);
27
28 if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
29 String nodeName = node.getNodeName();
30
31 if (nodeName == null) {
32 continue;
33 }
34
35 nodeName = SchemaNode.getElementName(nodeName);
36 // a simple-based type
37 if (node.getNodeName().equals("simpleContent")) {
38 // we're really just a simple type with attributes - nothing more to do
39 }
40 // a complex-based type
41 else if (node.getNodeName().equals("complexContent")) {
42 // we just contain elements, no text
43 }
44 // the following pretty much speak for themselves
45 else {
46 try {
47 Object child = SchemaNodeFactory.makeNode((Element) node);
48 if (child != null) {
49 this.children.add(child);
50 }
51 }
52 catch (SchemaException ex)
53 {
54 }
55 }
56 }
57 }
58
59 SchemaTypeMap.theMap.addType(this);
60 }
61
62 public String getName()
63 { return this.name;
64 }
65}
Note: See TracBrowser for help on using the repository browser.