Changeset 2810 for trunk/gsdl/perllib/doc.pm
- Timestamp:
- 2001-10-31T19:37:58+13:00 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/doc.pm
r2484 r2810 155 155 } 156 156 157 158 sub buffer_section_gml { 159 my $self = shift (@_); 160 my ($section, $suppress_subject_info) = @_; 161 162 $suppress_subject_info = 0 unless defined $suppress_subject_info; 163 my ($all_text,$data, $subsection); 164 157 sub buffer_section_xml { 158 my $self = shift (@_); 159 my ($section) = @_; 160 165 161 my $section_ptr = $self->_lookup_section ($section); 166 my ($section_num) = $section =~ /(\d+)$/;167 168 162 return "" unless defined $section_ptr; 169 163 170 # output the section header (including the section number171 # and metadata)172 173 $all_text = "<gsdlsection";174 $all_text .= " gsdlnum=\"$section_num\"" if defined $section_num;175 foreach $data (@{$section_ptr->{'metadata'}}) { 176 $all_text .= " $data->[0]=\"" . &_escape_text($data->[1]) . "\""177 unless $suppress_subject_info && $data->[0] eq "Subject"; 178 } 179 $all_text .= " >";164 my $all_text = "<Section>\n"; 165 $all_text .= " <Description>\n"; 166 167 # output metadata 168 foreach my $data (@{$section_ptr->{'metadata'}}) { 169 my $escaped_value = &_escape_text($data->[1]); 170 $all_text .= ' <Metadata name="' . $data->[0] . '">' . $escaped_value . "</Metadata>\n"; 171 } 172 173 $all_text .= " </Description>\n"; 180 174 181 175 # output the text 176 $all_text .= " <Content>\n"; 182 177 $all_text .= &_escape_text($section_ptr->{'text'}); 183 178 $all_text .= " </Content>\n"; 179 184 180 # output all the subsections 185 foreach $subsection (@{$section_ptr->{'subsection_order'}}) { 186 $all_text .= $self->buffer_section_gml("$section.$subsection", 187 $suppress_subject_info); 188 } 189 190 # output the closing tag 191 $all_text .= "</gsdlsection>\n"; 181 foreach my $subsection (@{$section_ptr->{'subsection_order'}}) { 182 $all_text .= $self->buffer_section_xml("$section.$subsection"); 183 } 184 185 $all_text .= "</Section>\n"; 192 186 193 187 return $all_text; 194 188 } 195 189 196 197 sub buffer_section_xml {198 my $self = shift (@_);199 my ($section, $dtd_metadata, $suppress_subject_info) = @_;200 201 $suppress_subject_info = 0 unless defined $suppress_subject_info;202 my ($all_text, $data, $subsection);203 204 my $section_ptr = $self->_lookup_section ($section);205 my ($section_num) = $section =~ /(\d+)$/;206 207 return "" unless defined $section_ptr;208 209 # output the section header (including the section number210 # and metadata)211 212 $all_text .= "<gsdlsection";213 $all_text .= " gsdlnum=\"$section_num\"" if defined $section_num;214 $all_text .= ">\n";215 216 $all_text .= " <metadata>\n";217 218 # output metadata219 foreach $data (@{$section_ptr->{'metadata'}}) {220 my $tag_name = $data->[0];221 222 # a tagname beginning with '/' (like </srclink>) will cause problems223 # so we'll escape any leading '/'224 $tag_name =~ s/^\//&\#47;/;225 226 my $tag_value = &_escape_text($data->[1]);227 228 unless ($suppress_subject_info && $tag_name eq "Subject")229 {230 if (defined $dtd_metadata)231 {232 $dtd_metadata->{$tag_name}++;233 }234 235 $all_text .= " <$tag_name>$tag_value</$tag_name>\n";236 }237 }238 239 $all_text .= " </metadata>\n";240 241 # output the text242 $all_text .= &_escape_text($section_ptr->{'text'});243 244 # output all the subsections245 foreach $subsection (@{$section_ptr->{'subsection_order'}}) {246 $all_text .= $self->buffer_section_xml("$section.$subsection",247 $dtd_metadata,248 $suppress_subject_info);249 }250 251 # output the closing tag252 $all_text .= "</gsdlsection>\n";253 254 return $all_text;255 }256 257 190 sub output_section { 258 191 my $self = shift (@_); 259 my ($handle, $section, $colname, $dtd_metadata, 260 $suppress_subject_info) = @_; 261 262 my $all_text = $self->buffer_section_xml($section, $dtd_metadata, 263 $suppress_subject_info); 264 265 # xml header 266 if (defined $collection) 267 { 268 my $xml_head 269 = '<? xml version="1.0" standalone="no" encoding="UTF-8" ?>'; 270 $xml_head .= "\n<!DOCTYPE gsdl:$colname SYSTEM \"$colname.dtd\">\n"; 271 $all_text = $xml_head.$all_text; 272 } 273 274 print $handle $all_text; 192 my ($handle, $section) = @_; 193 194 print $handle $self->buffer_section_xml($section); 275 195 } 276 196
Note:
See TracChangeset
for help on using the changeset viewer.