Harvard University Library - Library Digital Initiative
  Home 
  METS 
  JAXB 
  Toolkit 
  Procedural Construction 
  Validation 
  Marshalling / Unmarshalling 
  Implementation 
  Papers and Presentations 
 
  Printer-Friendly Version of Site 

  Harvard University Library 
 
  Office for Information Systems 
 
  Library Digital Initiative 

METS Java Toolkit / Procedural Construction
Draft Version 1.0 (alpha) 2002/03/15

The general recursive rule for procedural construction of a METS file is:

  1. The root document content model is the <mets> element
  2. For each element in the content model, instantiate the appropriate element object, set its attributes, define its content model, and then add itself to the content model of its parent:

Mets mets = new Mets ();
mets.setID ("1234");
...

  MetsHdr metsHdr = new MetsHdr ();
  metsHdr.setRECORDSTATUS ("Prod");
  ...

    Agent agent = new Agent ();
    agent.setROLE (Role.CREATOR);
    ...

      Name name = new Name ();
      name.setContent (new PCData ("S. L. Abrams"));
      ...

    agent.getContent ().add (name);
    ...

  metsHdr.getContent ().add (agent);
  ...

mets.getContent ().add (metsHdr);
...

  DmdSec dmdSec = new DmdSec ();
  dmdSec.setID ("abc");
  ...

    MdWrap mdWrap = new MdWrap ();
    mdWrap.setMDTYPE (Mdtype.DC);
    ...

      XmlData xmlData = new XmlData ();

        Any any = new Any ("my", "descMD");
        any.getAttributes ().add (new Attribute ("my",
                                  "attr", "value"));
        ...

          ...

        any.getContent ().add (...);
        ...

      xmlData.getContent ().add (any);
      ...

    mdWrap.getContent ().add (xmlWrap);
    ...

  DmdSec.getContent ().add (mdWrap);
  ...

mets.getContent ().add (dmdSec);
...

Once the entire content tree has been constructed, it can be validated and marshalled.

mets.validate ();
mets.marshal (System.out);


Stephen Abrams
Harvard University Library, Office for Information Systems
1280 Massachusetts Avenue, Suite 404
Cambridge, MA 02138
stephen_abrams@harvard.edu
Copyright © 2002 by the President and Fellows of Harvard College.
This information about the METS Java Toolkit is provided for evaluation purposes only.

The METS specification was developed as an initiative of the Digital Library Federation and is maintained by the Network Development and MARC Standards Office of the Library of Congress.
The toolkit is compliant with the JAXB API specification, copyright © 2001 Sun Microsystems, Inc.
The toolkit uses the XP parser, copyright © 1997,1998 James Clark.