File Coverage

lib/XML/Parser/REX.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 11 12 91.6


line stmt bran cond sub pod time code
1             package XML::Parser::REX;
2 1     1   72968 use warnings;
  1         3  
  1         40  
3 1     1   5 use strict;
  1         2  
  1         851  
4              
5             our $VERSION = '1.01';
6              
7              
8             # REX/Perl 1.0
9             # Robert D. Cameron "REX: XML Shallow Parsing with Regular Expressions",
10             # Technical Report TR 1998-17, School of Computing Science, Simon Fraser
11             # University, November, 1998.
12             # Copyright (c) 1998, Robert D. Cameron.
13             # The following code may be freely used and distributed provided that
14             # this copyright and citation notice remains intact and that modifications
15             # or additions are clearly identified.
16              
17             our $TextSE = "[^<]+";
18             our $UntilHyphen = "[^-]*-";
19             our $Until2Hyphens = "$UntilHyphen(?:[^-]$UntilHyphen)*-";
20             our $CommentCE = "$Until2Hyphens>?";
21             our $UntilRSBs = "[^\\]]*](?:[^\\]]+])*]+";
22             our $CDATA_CE = "$UntilRSBs(?:[^\\]>]$UntilRSBs)*>";
23             our $S = "[ \\n\\t\\r]+";
24             our $NameStrt = "[A-Za-z_:]|[^\\x00-\\x7F]";
25             our $NameChar = "[A-Za-z0-9_:.-]|[^\\x00-\\x7F]";
26             our $Name = "(?:$NameStrt)(?:$NameChar)*";
27             our $QuoteSE = "\"[^\"]*\"|'[^']*'";
28             our $DT_IdentSE = "$S$Name(?:$S(?:$Name|$QuoteSE))*";
29             our $MarkupDeclCE = "(?:[^\\]\"'><]+|$QuoteSE)*>";
30             our $S1 = "[\\n\\r\\t ]";
31             our $UntilQMs = "[^?]*\\?+";
32             our $PI_Tail = "\\?>|$S1$UntilQMs(?:[^>?]$UntilQMs)*>";
33             our $DT_ItemSE = "<(?:!(?:--$Until2Hyphens>|[^-]$MarkupDeclCE)|\\?$Name(?:$PI_Tail))|%$Name;|$S";
34             our $DocTypeCE = "$DT_IdentSE(?:$S)?(?:\\[(?:$DT_ItemSE)*](?:$S)?)?>?";
35             our $DeclCE = "--(?:$CommentCE)?|\\[CDATA\\[(?:$CDATA_CE)?|DOCTYPE(?:$DocTypeCE)?";
36             our $PI_CE = "$Name(?:$PI_Tail)?";
37             our $EndTagCE = "$Name(?:$S)?>?";
38             our $AttValSE = "\"[^<\"]*\"|'[^<']*'";
39             our $ElemTagCE = "$Name(?:$S$Name(?:$S)?=(?:$S)?(?:$AttValSE))*(?:$S)?/?>?";
40             our $MarkupSPE = "<(?:!(?:$DeclCE)?|\\?(?:$PI_CE)?|/(?:$EndTagCE)?|(?:$ElemTagCE)?)";
41             our $XML_SPE = "$TextSE|$MarkupSPE";
42              
43              
44             sub ShallowParse {
45 1     1 0 8 my($XML_document) = @_;
46 1         428 return $XML_document =~ /$XML_SPE/g;
47             }
48              
49              
50             1;
51              
52              
53             __END__