Index: trunk/gsdl/perllib/classify/AZList.pm
===================================================================
--- trunk/gsdl/perllib/classify/AZList.pm	(revision 315)
+++ trunk/gsdl/perllib/classify/AZList.pm	(revision 316)
@@ -11,5 +11,4 @@
 
     return bless {
-	'OID'=>"NULL",
 	'list'=>{},
 	'metaname' => $options[0]
@@ -23,16 +22,4 @@
 }
 
-sub set_OID {
-    my $self = shift (@_);
-    my ($OID) = @_;
-
-    $self->{'OID'} = $OID;
-}
-
-sub get_OID {
-    my $self = shift (@_);
-    return $self->{'OID'};
-}
-
 sub classify {
     my $self = shift (@_);
@@ -45,5 +32,4 @@
     # if this document doesn't contain the metadata element we're
     # sorting by we won't include it in this classification
-
     if (defined $metavalue) {
 	if ($self->{'metaname'} eq 'Creator') {
@@ -59,26 +45,42 @@
 }
 
-sub output_classify_info {
-    my $self = shift (@_);
-    my ($handle) = @_;
+sub get_classify_info {
+    my $self = shift (@_);
 
     my @classlist = sort {$self->{'list'}->{$a} cmp $self->{'list'}->{$b};} keys %{$self->{'list'}};
     my $subclasses = $self->splitlist (\@classlist);
 
+    my ($classifyinfo);
+
     if (scalar @$subclasses) {
-	
-	my @contents = ();
-	map { push (@contents, "\".$_->[1]"); } @$subclasses;
-	# write out top level entry
-	$self->output_entry ($handle, $self->{'OID'}, $self->{'metaname'}, \@contents, "AZList");
-
-	# write out the entries for each sub-classification
-	map {$self->output_entry ($handle, "$self->{'OID'}.$_->[1]", $_->[0], $_->[2]);} @$subclasses;
+	$classifyinfo = $self->get_entry ($self->{'metaname'}, "AZList");
+	foreach $subclass (@$subclasses) {
+	    my $tempclassify = $self->get_entry($subclass->[0], "AZList");
+	    foreach $subsubOID (@{$subclass->[2]}) {
+		push (@{$tempclassify->{'contains'}}, {'OID'=>$subsubOID});
+	    }
+	    push (@{$classifyinfo->{'contains'}}, $tempclassify);
+	}
  
     } else {
-
-	# write out top level entry
-	$self->output_entry ($handle, $self->{'OID'}, $self->{'metaname'}, \@classlist, "AZList");
-    }
+	$classifyinfo = $self->get_entry($self->{'metaname'}, "AZList");
+	foreach $subOID (@classlist) {
+	    push (@{$classifyinfo->{'contains'}}, {'OID'=>$subOID});
+	}
+    }
+
+    return $classifyinfo;
+}
+
+sub get_entry {
+    my $self = shift (@_);
+    my ($title, $classifytype) = @_;
+    
+    # organise into classification structure
+    my %classifyinfo = ('classifytype'=>$classifytype,
+			'Title'=>$title,
+			'contains'=>[]);
+
+    return \%classifyinfo;
 }
 
@@ -199,19 +201,4 @@
 }
 
-sub output_entry {
-    my $self = shift (@_);
-    my ($handle, $OID, $title, $contentsref, $classifytype) = @_;
-    
-    print $handle "[$OID]\n";
-    print $handle "<doctype>classify\n";
-    print $handle "<hastxt>0\n";
-    print $handle "<Title>$title\n";
-    print $handle "<classifytype>$classifytype\n" if defined $classifytype;
-    if (scalar @$contentsref) {
-	print $handle "<contains>", join (";", @$contentsref), "\n";
-    }
-    print $handle '-' x 70, "\n";
-}
-
 # format an english name for sorting
 # i.e. convert to lowercase, put surname before
Index: trunk/gsdl/perllib/classify/Hierarchy.pm
===================================================================
--- trunk/gsdl/perllib/classify/Hierarchy.pm	(revision 315)
+++ trunk/gsdl/perllib/classify/Hierarchy.pm	(revision 316)
@@ -25,7 +25,6 @@
 
     return bless {
-	'OID'=>"NULL",
-	'descriptorlist'=>{},
-	'locatorlist'=>{},
+	'descriptorlist'=>{}, # first field in subject file
+	'locatorlist'=>{},    # second field in subject file
 	'subjectfile' => $subjectfile,
 	'metaname' => $options[1]
@@ -35,9 +34,11 @@
 sub init {
     my $self = shift (@_);
-    my $contenthash = {};
 
     # read in the subject file
     my $list = &cfgread::read_cfg_file ($self->{'subjectfile'}, undef, '^[^#]?\w');
     
+    # $list is a hash that is indexed by the descriptor. The contents of this
+    # hash is a list of two items. The first item is the OID and the second item
+    # is the title
     foreach $descriptor (keys (%$list)) {
 	$self->{'descriptorlist'}->{$descriptor} = $list->{$descriptor}->[0];
@@ -46,34 +47,5 @@
 	    $self->{'locatorlist'}->{$list->{$descriptor}->[0]}->{'contents'} = [];
 	}
-	
-	my $OID = $list->{$descriptor}->[0];
-	if ($OID =~ s/\.(\d+)$//) {
-	    # $OID is now the parents OID
-	    my $child = $1;
-	    $contenthash->{$OID} = [] unless defined $contenthash->{$OID};
-	    push (@{$contenthash->{$OID}}, $child);
-	}
     }
-
-    # need to shove each OID into the contents of its parent
-    # do this separately in case classifications aren't in order in 
-    # subject file
-    foreach $OID (keys (%$contenthash)) {
-	push (@{$self->{'locatorlist'}->{$OID}->{'contents'}}, 
-	      sort numerically @{$contenthash->{$OID}});
-	map { $_ = "\".$_"; } @{$self->{'locatorlist'}->{$OID}->{'contents'}};
-    }
-}
-
-sub set_OID {
-    my $self = shift (@_);
-    my ($OID) = @_;
-
-    $self->{'OID'} = $OID;
-}
-
-sub get_OID {
-    my $self = shift (@_);
-    return $self->{'OID'};
 }
 
@@ -94,39 +66,60 @@
 }
 
-sub output_classify_info {
+
+sub get_classify_info {
     my $self = shift (@_);
-    my ($handle) = @_;
-    my $topcontents = [];
-
+    
     my $list = $self->{'locatorlist'};
 
+    my $classifyinfo = $self->get_entry ($self->{'metaname'}, "Hierarchy");
     foreach $OID (keys (%$list)) {
-	$self->output_entry ($handle, "$self->{'OID'}.$OID", 
-			     $list->{$OID}->{'title'}, $list->{$OID}->{'contents'});
-	push (@$topcontents, $OID) if $OID !~ /\./;
+	my $tempinfo = $self->get_OID_entry ($OID, $classifyinfo, $list->{$OID}->{'title'}, "Hierarchy");
+	foreach $subOID (@{$list->{$OID}->{'contents'}}) {
+	    push (@{$tempinfo->{'contains'}}, {'OID'=>$subOID});
+	}
     }
 
-    # top level of classification
-    map { $_ = "\".$_"; } sort numerically @$topcontents;
-    $self->output_entry ($handle, $self->{'OID'}, $self->{'metaname'}, 
-			 $topcontents, "Hierarchy");
+    return $classifyinfo;
 }
 
-sub output_entry {
+
+sub get_OID_entry {
     my $self = shift (@_);
-    my ($handle, $OID, $title, $contentsref, $classifytype) = @_;
+    my ($OID, $classifyinfo, $title, $classifytype) = @_;
+
+    $OID = "" unless defined $OID;
+    $OID =~ s/^\.+//;
     
-    print $handle "[$OID]\n";
-    print $handle "<doctype>classify\n";
-    print $handle "<hastxt>0\n";
-    print $handle "<Title>$title\n";
-    print $handle "<classifytype>$classifytype\n" if defined $classifytype;
-    if (scalar @$contentsref) {
-	print $handle "<contains>", join (";", @$contentsref), "\n";
+    my ($headOID, $tailOID) = $OID =~ /^(\d+)(.*)$/;
+    $tailOID = "" unless defined $tailOID;
+
+
+    if (!defined $headOID) {
+	$classifyinfo->{'Title'} = $title;
+	$classifyinfo->{'classifytype'} = $classifytype;
+	return $classifyinfo;
     }
-    print $handle '-' x 70, "\n";
+
+    $classifyinfo->{'contains'} = [] unless defined $classifyinfo->{'contains'};
+    
+    # add entries to the contains list until we have one for headOID
+    while (scalar(@{$classifyinfo->{'contains'}}) < $headOID) {
+	push (@{$classifyinfo->{'contains'}}, $self->get_entry("", $classifytype));
+    }
+
+    return $self->get_OID_entry ($tailOID, $classifyinfo->{'contains'}->[($headOID-1)], $title, $classifytype);
 }
 
-sub numerically { $a <=> $b; }
+sub get_entry {
+    my $self = shift (@_);
+    my ($title, $classifytype) = @_;
+    
+    # organise into classification structure
+    my %classifyinfo = ('classifytype'=>$classifytype,
+			'Title'=>$title,
+			'contains'=>[]);
+
+    return \%classifyinfo;
+}
 
 1;
Index: trunk/gsdl/perllib/classify/List.pm
===================================================================
--- trunk/gsdl/perllib/classify/List.pm	(revision 315)
+++ trunk/gsdl/perllib/classify/List.pm	(revision 316)
@@ -20,5 +20,4 @@
 
     return bless {
-	'OID'=>"NULL",
 	'list'=>$list,
 	'metaname' => $options[0]
@@ -34,16 +33,4 @@
 	$self->{'list'} = [];
     }
-}
-
-sub set_OID {
-    my $self = shift (@_);
-    my ($OID) = @_;
-
-    $self->{'OID'} = $OID;
-}
-
-sub get_OID {
-    my $self = shift (@_);
-    return $self->{'OID'};
 }
 
@@ -73,29 +60,29 @@
 }
 
-sub output_classify_info {
+sub get_classify_info {
     my $self = shift (@_);
-    my ($handle) = @_;
 
     my $classifytitle = "List";
     my $contains = "";
+    my @list = ();
     if (defined $self->{'metaname'}) {
 	$classifytitle = $self->{'metaname'};
 	if (keys %{$self->{'list'}}) {
-	    $contains = join (";", sort {$self->{'list'}->{$a} 
-					 cmp $self->{'list'}->{$b};} keys %{$self->{'list'}}) . "\n";
+	    @list = sort {$self->{'list'}->{$a} 
+			  cmp $self->{'list'}->{$b};} keys %{$self->{'list'}};
 	}
     } else {
-	if (scalar (@{$self->{'list'}}) > 0) {
-	    $contains = join (";", @{$self->{'list'}}) . "\n";
-	}
+	@list = @{$self->{'list'}};
     }
 
-    print $handle "[$self->{'OID'}]\n";
-    print $handle "<doctype>classify\n";
-    print $handle "<hastxt>0\n";
-    print $handle "<classifytype>List\n";
-    print $handle "<Title>$classifytitle\n";
-    print $handle "<contains>$contains\n" if $contains =~ /\w/; 
-    print $handle '-' x 70, "\n";
+    # organise into classification structure
+    my %classifyinfo = ('classifytype'=>'List',
+			'Title'=>$classifytitle,
+			'contains'=>[]);
+    foreach $OID (@list) {
+	push (@{$classifyinfo{'contains'}}, {'OID'=>$OID});
+    }
+
+    return \%classifyinfo;
 }
 
