source: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/NamespaceFactory.java@ 8461

Last change on this file since 8461 was 8461, checked in by kjdon, 20 years ago

added in Chi's changes for METS documents. mostly the addition of new/improved parseXML methods

  • Property svn:keywords set to Author Date Id Revision
File size: 1.7 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 { return new GSDL3Namespace();
14 }
15
16 public static METSNamespace initNamespace(String name)
17 { if (name.equals(GSDL3Namespace.GSDL3_NAMESPACE_ID))
18 { return new GSDL3Namespace();
19 }
20 return new SimpleNamespace(name);
21 }
22
23 public static METSNamespace initNamespace(String name, METSLocation location)
24 { if (name.equals(GSDL3Namespace.GSDL3_NAMESPACE_ID))
25 { return new GSDL3Namespace(location);
26 }
27 return new SimpleNamespace(name, location);
28 }
29
30 /**
31 * TODO: parse the document in based upon its namespace
32 */
33 public static METSNamespace initNamespace(String name, Element element)
34 { //return null;
35 return new SimpleNamespace(name);
36 }
37
38 public static METSNamespace parseXML(Element element)
39 { METSNamespace namespace = null;
40
41 String mdType = element.getAttribute("MDType");
42 String mimeType = element.getAttribute("mimeType");
43
44 if (element.getNodeName().equals("mets:mdWrap"))
45 { namespace = initNamespace(mdType, element);
46 }
47 else if (element.getNodeName().equals("mets:mdRef"))
48 { // just a file wrapper on the metadata...
49 String location = element.getAttribute("xlink:href");
50 String locationType = element.getAttribute("LOCTYPE");
51
52 try
53 {
54 METSLocation metsLocation = new METSLocation(locationType, location);
55 namespace = initNamespace(mdType, metsLocation);
56 }
57 catch (java.net.MalformedURLException ex)
58 { // TODO: Error, should never happen in the case of Greenstone-exported XML
59 }
60 }
61 return namespace;
62 }
63}
Note: See TracBrowser for help on using the repository browser.