source: trunk/greenstone3-extensions/gs3build/src/org/greenstone/gsdl3/gs3build/schema/SchemaAttribute.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.1 KB
Line 
1package org.greenstone.gsdl3.gs3build.schema;
2
3import org.w3c.dom.Element;
4
5public class SchemaAttribute
6{
7 public final static String ATTRIBUTE_TYPE_STRING = "String";
8
9 String name;
10 String type;
11 boolean required;
12
13 public SchemaAttribute(Element element) throws SchemaException
14 {
15 // get the name - things are totally unworkable if it doesn't exist!
16 this.name = element.getAttribute("name");
17 if (this.name == null) {
18 throw new SchemaException("All attributes must have names");
19 }
20
21 // ids are quite important in some metadata schema - copy that too
22 String id = element.getAttribute("id");
23
24 // get the required field - we don't actually cope with "prohibited" at the moment!
25 String use = element.getAttribute("use");
26 this.required = (use != null && use.equals("required"));
27
28 // and the type - we don't reflect any further upon this, actually
29 this.type = element.getAttribute("type");
30 if (this.type == null) {
31 this.type = SchemaAttribute.ATTRIBUTE_TYPE_STRING;
32 }
33
34 // Constraints should now be added, but at present that is not done, as we
35 // are non-validating!
36 }
37}
Note: See TracBrowser for help on using the repository browser.