source: trunk/greenstone3-extensions/gs3build/src/org/greenstone/gsdl3/gs3build/metadata/NamespaceFactory.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.metadata;
2
3import org.w3c.dom.Document;
4import org.w3c.dom.Element;
5import org.w3c.dom.NamedNodeMap;
6import org.w3c.dom.Node;
7import org.w3c.dom.NodeList;
8import org.w3c.dom.Text;
9
10public class NamespaceFactory
11{
12 public static METSNamespace initNamespace()
13 {
14 return new GSDL3Namespace();
15 }
16
17 public static METSNamespace initNamespace(String name)
18 {
19 if (name.equals(GSDL3Namespace.GSDL3_NAMESPACE_ID)) {
20 return new GSDL3Namespace();
21 }
22 return new SimpleNamespace(name);
23 }
24
25 public static METSNamespace initNamespace(String name, METSLocation location)
26 {
27 if (name.equals(GSDL3Namespace.GSDL3_NAMESPACE_ID)){
28 return new GSDL3Namespace(location);
29 }
30 return new SimpleNamespace(name, location);
31 }
32
33 /**
34 * TODO: parse the document in based upon its namespace
35 */
36 public static METSNamespace initNamespace(String name, Element element)
37 {
38 //return null;
39 return new SimpleNamespace(name);
40 }
41
42 public static METSNamespace parseXML(Element element)
43 {
44 METSNamespace namespace = null;
45
46 //String mdType = element.getAttribute("MDType");
47 //String mdType =element.getAttribute("MDTYPE");
48
49 String othermdType = element.getAttribute("OTHERMDTYPE");
50 String mimeType = element.getAttribute("mimeType");
51
52 if (element.getNodeName().equals("mets:mdWrap")) {
53 namespace = initNamespace(othermdType, element);
54 }
55 else if (element.getNodeName().equals("mets:mdRef")) {
56 String mdType = element.getAttribute("MDType");
57 // just a file wrapper on the metadata...
58 String location = element.getAttribute("xlink:href");
59 String locationType = element.getAttribute("LOCTYPE");
60
61 try {
62 METSLocation metsLocation = new METSLocation(locationType, location);
63 namespace = initNamespace(mdType, metsLocation);
64 }
65 catch (java.net.MalformedURLException ex) {
66 // TODO: Error, should never happen in the case of Greenstone-exported XML
67 }
68 }
69 return namespace;
70 }
71}
Note: See TracBrowser for help on using the repository browser.