+ # don't use any other entities than " ' < > and &
+ # (while using non XML::DOM - version)
+ #
+ for ('metaon', 'metaoff') {
+ $self -> {$_} =~ s/"/"/g; $self -> {$_} =~ s/'/'/g;
+ $self -> {$_} =~ s/</</g; $self -> {$_} =~ s/>/>/g;
+ $self -> {$_} =~ s/&/&/g;
+ }
+
+ $self -> {parsed} = {};
+ while ($template =~ m|<Scrap\s+(?:id\s*=\s*"([^"]+)")?\s*>\s*<!\[CDATA\[([^\]]*(?:\](?!\]>)[^\]]*)*)\]\]>\s*</Scrap\s*>|g) {
+
+ my ($name, $content) = ($1, $2);
+
+ croak "Element 'Scrap' requires attribute 'id' in template file '$filename'"
+ unless (defined $name and length $name);
+
+ croak "double defined id '$name' in template file '$filename'"
+ if (exists ($self -> {parsed} -> {$name}));
+
+ croak "use '/^[_a-zA-Z]\\S*\$/' for 'Scrap'-ids in template file '$filename' (wrong: '$name')"
+ unless ($name =~ /^[_a-zA-Z]\S*$/);
+
+ $content =~ s/^\s+//; $content =~ s/\s+$//;
+ $self -> {parsed} -> {$name} = $content;
+ }
+
+ return 1; # looks fine
+ }
+
+ return; # anything failed (??)