Changeset 13148
- Timestamp:
- 2006-10-20T12:37:50+13:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/XMLPlug.pm
r12844 r13148 79 79 'Entity' => \&Entity, 80 80 'Doctype' => \&Doctype, 81 'Default' => \&Default 82 }); 81 'Default' => \&Default, 82 }); 83 83 84 $self->{'parser'} = $parser; 84 85 … … 168 169 $self->{'processor'} = $processor; 169 170 $self->{'metadata'} = $metadata; 171 172 173 ##call the inheriting plugin's get_doctype method to decide whether to carry on the parsing 174 if (open(XMLIN,"<$filename")) { 175 my $doctype = $self->get_doctype(); 176 ## check whether the doctype have the same name as the root element tag 177 while (defined (my $line = <XMLIN>)) { 178 ## find the root element 179 if ($line =~ /<(\w+)[\s>]/){ 180 my $root = $1; 181 if ($root !~ $doctype){ 182 close(XMLIN); 183 return undef; 184 } 185 else{ 186 close(XMLIN); 187 last; 188 } 189 } 190 } 191 } 192 170 193 171 194 eval { … … 275 298 sub xml_doctype { 276 299 my $self = shift(@_); 300 277 301 my ($expat, $name, $sysid, $pubid, $internal) = @_; 278 302 die "XMLPlug Cannot process XML document with DOCTYPE of $name"; 279 303 } 304 305 # the inheriting class must implement this method to tell whether to parse this doc type 306 sub get_doctype { 307 my $self = shift(@_); 308 die "The inheriting class must implement this method"; 309 } 310 311 280 312 281 313 # Called for every start tag. The $_ variable will contain a copy of the
Note:
See TracChangeset
for help on using the changeset viewer.