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/METSStructure.java

    r6348 r8461  
    1212import java.sql.ResultSet;
    1313
     14import org.w3c.dom.Element;
     15import org.w3c.dom.NodeList;
     16
    1417import org.greenstone.gsdl3.gs3build.doctypes.DocumentInterface;
    1518
     
    2225  String label;
    2326  String type;
     27    METSDivision divGroup;
    2428
    2529  public static final String STRUCTURE_TYPE = "Structure";
     
    3034    this.label    = label;
    3135    this.type     = type;
     36    this.divGroup = null;
    3237  }
    3338
     
    108113  }
    109114
     115
     116     /*
     117      *
     118      * parse an XML Element as a METSStructure Section
     119      *
     120      * @param <code>Element</code> the XML element which represents
     121      *  the mets:structMap itself
     122      */
     123   
     124     public static METSStructure parseXML(Element element)
     125     {
     126    String structId = element.getAttribute("ID");
     127    String structType = element.getAttribute("TYPE");
     128    String structLabel = element.getAttribute("LABEL");
     129 
     130    METSStructure thisStruct = new METSStructure (structId, structType, structLabel);
     131   
     132    NodeList divSecs = element.getChildNodes();
     133    if (divSecs != null) {
     134        for (int c = 0; c < divSecs.getLength(); c++) {
     135        if (divSecs.item(c).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE){
     136            continue;
     137        }
     138        Element divElement = (Element) divSecs.item(c);
     139        String divName = divElement.getNodeName();
     140        if (divName.equals("mets:div")) {
     141            METSDivision division = METSDivision.parseXML(divElement);
     142            thisStruct.addDivision(division);
     143        } else {
     144            System.err.println("Error: mets:structMap was expecting mets:div but got "+divName);
     145        }
     146        }
     147    }
     148    return thisStruct;
     149     }
     150 
    110151  /**
    111152   *  Write this structure in XML(METS) format to a <code>PrintWriter</code>
Note: See TracChangeset for help on using the changeset viewer.