Changeset 8698


Ignore:
Timestamp:
2004-11-30T11:02:01+13:00 (19 years ago)
Author:
chi
Message:

Modifications for the validated METS format and program layout change

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/NamespaceFactory.java

    r8461 r8698  
    1010public class NamespaceFactory
    1111{
    12     public static METSNamespace initNamespace()
    13     {   return new GSDL3Namespace();
     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();
    1421    }
     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");
    1548
    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);
     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);
    2154    }
    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);
     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        }
    2868    }
    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     }
     69    return namespace;
     70    }
    6371}
Note: See TracChangeset for help on using the changeset viewer.