Ignore:
Timestamp:
2004-11-05T10:10:44+13:00 (20 years ago)
Author:
kjdon
Message:

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

File:
1 edited

Legend:

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

    r7187 r8461  
    1111import java.sql.SQLException;
    1212import java.sql.ResultSet;
     13
     14import org.w3c.dom.Element;
     15import org.w3c.dom.NodeList;
    1316
    1417import org.greenstone.gsdl3.gs3build.doctypes.DocumentID;
     
    289292    }
    290293  }
     294
     295      /*  Parse an XML Element as a METSDivision section
     296      *
     297      *  @param <code>Element</code> the XML element which represents
     298      *  the mets:div itself
     299      */
     300   
     301     public static METSDivision parseXML(Element element)
     302     {
     303    METSDivision thisDivision = null;
     304 
     305    String divId = element.getAttribute("ID");
     306    String divType = element.getAttribute("TYPE");
     307    String divOrder = element.getAttribute("ORDER");
     308    String divOrderLabel = element.getAttribute("ORDERLABEL");
     309    String divUserLabel = element.getAttribute("LABEL");
     310    String divMetaRef = element.getAttribute("DMDID");
     311   
     312    thisDivision = new METSDivision(divId, divOrder,divOrderLabel, divUserLabel, divType);
     313       
     314    thisDivision.addMetadataReference(divMetaRef);
     315 
     316    NodeList children = element.getChildNodes();
     317 
     318    for (int c = 0; c < children.getLength(); c++){
     319        if (children.item(c).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE){
     320        continue;
     321        }
     322        Element child = (Element) children.item(c);
     323        String childName = child.getNodeName();
     324 
     325        if (childName.equals("mets:fptr")) {
     326       
     327        METSDivision.fptr_parseXML(thisDivision, child);
     328        } else if (childName.equals("mets:div")) {
     329        METSDivision division = METSDivision.parseXML(child);
     330        thisDivision.addDivision(division);
     331        } else {
     332        System.err.println("Error: mets:div expected mets:div or mets:fptr, but got " + childName);
     333        }
     334    }
     335    return thisDivision;
     336     }
     337 
     338 
     339 
     340     /**
     341      * Parse an XML element as a  METSFptr Section
     342      * @param <code>Element</code> the XML element which represents the mets:fptr itself
     343      */
     344     private static void fptr_parseXML(METSDivision thisDivision, Element element)
     345     {
     346    String fileRef = element.getAttribute("FILEID");
     347    thisDivision.addFileReference(fileRef);
     348     }
     349 
     350     /**
     351
    291352
    292353  /**
Note: See TracChangeset for help on using the changeset viewer.