Copying File Formats

The following procedure, copyObjClass, creates a copy of a file format by reading the setKeys of the source and writing them into the new file format. The procedure has two arguments, the names of the source and destination file formats (in this order).

# $Id: copyObjClass.tcl, v. 0.9 2010-11-23 13:51:46
#
# Last changed: 2010-11-23
# Use at your own risk!
#
# Purpose:
#   Creates a new file fromat from an existing one
# Parameters:
#   Name of source file format,
#   Name of file format to create

proc copyObjClass {sourceClassName destClassName} {
  set sourceClassType [objClass withName $sourceClassName get objType]

  set setKeys [objClass withName $sourceClassName get setKeys]
  set nameIndex [lsearch $setKeys {name}]
  set setKeys [lreplace $setKeys $nameIndex $nameIndex]
  set values [eval [list objClass withName $sourceClassName mget] $setKeys]

  set setValues [list]
  foreach key $setKeys value $values {
    lappend setValues $key $value
  }

  eval [list objClass create name $destClassName objType $sourceClassType] $setValues
}

Please save the script to a single Tcl file. Open a Tcl shell, connect to the Content Manager, and read the Tcl file using source. You can now use the procedure. Example:

copyObjClass articleDocument newsDocument