示例#1
0
  /**
   * Render the complete METS document.
   *
   * @param context session context.
   * @param contentHandler XML content handler.
   * @param lexicalHandler XML lexical handler.
   * @throws org.dspace.app.xmlui.wing.WingException passed through.
   * @throws org.xml.sax.SAXException passed through.
   * @throws org.dspace.content.crosswalk.CrosswalkException passed through.
   * @throws java.io.IOException passed through.
   * @throws java.sql.SQLException passed through.
   */
  public final void renderMETS(
      Context context, ContentHandler contentHandler, LexicalHandler lexicalHandler)
      throws WingException, SAXException, CrosswalkException, IOException, SQLException {
    this.contentHandler = contentHandler;
    this.lexicalHandler = lexicalHandler;
    this.namespaces = new NamespaceSupport();

    // Declare our namespaces
    namespaces.pushContext();
    namespaces.declarePrefix("mets", METS.URI);
    namespaces.declarePrefix("xlink", XLINK.URI);
    namespaces.declarePrefix("xsi", XSI.URI);
    namespaces.declarePrefix("dim", DIM.URI);
    contentHandler.startPrefixMapping("mets", METS.URI);
    contentHandler.startPrefixMapping("xlink", XLINK.URI);
    contentHandler.startPrefixMapping("xsi", XSI.URI);
    contentHandler.startPrefixMapping("dim", DIM.URI);

    // Send the METS element
    AttributeMap attributes = new AttributeMap();
    attributes.put("ID", getMETSID());
    attributes.put("PROFILE", getMETSProfile());
    attributes.put("LABEL", getMETSLabel());
    String objid = getMETSOBJID();
    if (objid != null) {
      attributes.put("OBJID", objid);
    }

    // Include the link for editing the item
    objid = getMETSOBJEDIT();
    if (objid != null) {
      attributes.put("OBJEDIT", objid);
    }

    startElement(METS, "METS", attributes);

    // If the user requested no specific sections then render them all.
    boolean all = (sections.isEmpty());

    if (all || sections.contains("metsHdr")) {
      renderHeader();
    }
    if (all || sections.contains("dmdSec")) {
      renderDescriptiveSection();
    }
    if (all || sections.contains("amdSec")) {
      renderAdministrativeSection();
    }
    if (all || sections.contains("fileSec")) {
      renderFileSection(context);
    }
    if (all || sections.contains("structMap")) {
      renderStructureMap();
    }
    if (all || sections.contains("structLink")) {
      renderStructuralLink();
    }
    if (all || sections.contains("behaviorSec")) {
      renderBehavioralSection();
    }

    // FIXME: this is not a met's section, it should be removed
    if (all || sections.contains("extraSec")) {
      renderExtraSections();
    }

    endElement(METS, "METS");
    contentHandler.endPrefixMapping("mets");
    contentHandler.endPrefixMapping("xlink");
    contentHandler.endPrefixMapping("dim");
    namespaces.popContext();
  }
 public void startPrefixMapping(String prefix, String uri) throws SAXException {
   super.startPrefixMapping(prefix, uri);
   nsSupport.pushContext();
   nsSupport.declarePrefix(prefix, uri);
 }