deprecated/buildtools/buildsystemtools/lib/XML/Checker.pm
author lorewang
Thu, 11 Nov 2010 11:26:32 +0800
changeset 677 44e49837144a
parent 655 3f65fd25dfd4
permissions -rw-r--r--
update release info
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
655
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     1
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     2
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     3
# TO DO
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     4
# - update docs regarding PerlSAX interface
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     5
# - add current node to error context when checking DOM subtrees
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     6
# - add parsed Entity to test XML files
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     7
# - free circular references
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     8
# - Implied handler?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     9
# - Notation, Entity, Unparsed checks, Default handler?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    10
# - check no root element (it's checked by expat) ?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    11
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    12
package XML::Checker::Term;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    13
use strict;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    14
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    15
sub new     
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    16
{ 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    17
    my ($class, %h) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    18
    bless \%h, $class;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    19
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    20
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    21
sub str     
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    22
{ 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    23
    '<' . $_[0]->{C} . $_[0]->{N} . '>'
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    24
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    25
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    26
sub re
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    27
{ 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    28
    $_[0]->{S} 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    29
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    30
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    31
sub rel 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    32
{ 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    33
    my $self = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    34
    defined $self->{SL} ? @{ $self->{SL} } : ( $self->{S} );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    35
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    36
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    37
sub debug
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    38
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    39
    my $t = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    40
    my ($c, $n, $s) = ($t->{C}, $t->{N}, $t->{S});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    41
    my @sl = $t->rel;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    42
    "{C=$c N=$n S=$s SL=@sl}";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    43
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    44
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    45
#-------------------------------------------------------------------------
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    46
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    47
package XML::Checker::Context;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    48
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    49
sub new
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    50
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    51
    my ($class) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    52
    my $scalar;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    53
    bless \$scalar, $class;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    54
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    55
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    56
sub Start {}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    57
sub End   {}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    58
sub Char  {}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    59
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    60
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    61
# The initial Context when checking an entire XML Document
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    62
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    63
package XML::Checker::DocContext;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    64
use vars qw( @ISA );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    65
@ISA = qw( XML::Checker::Context );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    66
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    67
sub new
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    68
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    69
#??checker not used
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    70
    my ($class, $checker) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    71
    bless { }, $class;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    72
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    73
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    74
sub setRootElement
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    75
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    76
    $_[0]->{RootElement} = $_[1];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    77
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    78
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    79
sub Start 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    80
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    81
    my ($self, $checker, $tag) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    82
    if (exists $self->{Elem})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    83
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    84
	my $tags = join (", ", @{$self->{Elem}});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    85
	$checker->fail (155, "more than one root Element [$tags]");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    86
	push @{$self->{Elem}}, $tag;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    87
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    88
    else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    89
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    90
	$self->{Elem} = [ $tag ];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    91
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    92
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    93
    my $exp_root = $self->{RootElement};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    94
    $checker->fail (156, "unexpected root Element [$tag], expected [$exp_root]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    95
	if defined ($exp_root) and $tag ne $exp_root;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    96
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    97
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    98
sub debug
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    99
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   100
    my $self = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   101
    "DocContext[Count=" . $self->{Count} . ",Root=" . 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   102
	$self->{RootElement} . "]";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   103
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   104
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   105
package XML::Checker::Context::ANY;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   106
use vars qw( @ISA );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   107
@ISA = qw( XML::Checker::Context );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   108
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   109
# No overrides, because everything is accepted
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   110
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   111
sub debug { "XML::Checker::Context::ANY" }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   112
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   113
package XML::Checker::Context::EMPTY;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   114
use vars qw( @ISA $ALLOW_WHITE_SPACE );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   115
@ISA = qw( XML::Checker::Context );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   116
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   117
$ALLOW_WHITE_SPACE = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   118
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   119
sub debug { "XML::Checker::Context::EMPTY" }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   120
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   121
sub Start
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   122
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   123
    my ($self, $checker, $tag) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   124
    $checker->fail (152, "Element should be EMPTY, found Element [$tag]");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   125
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   126
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   127
sub Char
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   128
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   129
    my ($self, $checker, $str) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   130
    $checker->fail (153, "Element should be EMPTY, found text [$str]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   131
	unless ($ALLOW_WHITE_SPACE and $checker->isWS ($str));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   132
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   133
    # NOTE: if $ALLOW_WHITE_SPACE = 1, the isWS call does not only check
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   134
    # whether it is whitespace, but it also informs the checker that this 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   135
    # might be insignificant whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   136
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   137
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   138
#?? what about Comments
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   139
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   140
package XML::Checker::Context::Children;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   141
use vars qw( @ISA );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   142
@ISA = qw( XML::Checker::Context );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   143
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   144
sub new
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   145
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   146
    my ($class, $rule) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   147
    bless { Name => $rule->{Name}, RE => $rule->{RE}, Buf => "", N => 0 }, $class;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   148
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   149
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   150
sub phash
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   151
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   152
    my $href = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   153
    my $str = "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   154
    for (keys %$href)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   155
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   156
	$str .= ' ' if $str;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   157
	$str .= $_ . '=' . $href->{$_};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   158
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   159
    $str;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   160
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   161
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   162
sub debug
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   163
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   164
    my $self = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   165
    "Context::Children[Name=(" . phash ($self->{Name}) . ",N=" . $self->{N} .
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   166
	",RE=" . $self->{RE} . ",Buf=[" . $self->{Buf} . "]";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   167
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   168
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   169
sub Start
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   170
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   171
    my ($self, $checker, $tag) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   172
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   173
#print "Children.Start tag=$tag rule=$checker drule=" . $checker->debug . "\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   174
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   175
    if (exists $self->{Name}->{$tag})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   176
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   177
#print "Buf=[".$self->{Buf}. "] tag=[" . $self->{Name}->{$tag}->{S} . "]\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   178
	$self->{Buf} .= $self->{Name}->{$tag}->{S};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   179
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   180
    else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   181
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   182
	$checker->fail (157, "unexpected Element [$tag]", 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   183
			ChildElementIndex => $self->{N})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   184
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   185
    $self->{N}++;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   186
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   187
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   188
sub decode
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   189
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   190
    my ($self) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   191
    my $re = $self->{RE};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   192
    my $name = $self->{Name};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   193
    my $buf = $self->{Buf};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   194
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   195
    my %s = ();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   196
    while (my ($key, $val) = each %$name)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   197
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   198
	$s{$val->{S}} = $key;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   199
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   200
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   201
    my ($len) = scalar (keys %$name);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   202
    $len = length $len;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   203
    my $dots = "[^()*+?]" x $len;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   204
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   205
    $buf =~ s/($dots)/$s{$1} . ","/ge;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   206
    chop $buf;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   207
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   208
    $re =~ s/($dots)/"(" . $s{$1} . ")"/ge;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   209
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   210
    "Found=[$buf] RE=[$re]"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   211
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   212
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   213
sub End
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   214
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   215
    my ($self, $checker) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   216
    my $re = $self->{RE};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   217
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   218
#print "End " . $self->debug . "\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   219
    $checker->fail (154, "bad order of Elements " . $self->decode)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   220
	unless $self->{Buf} =~ /^$re$/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   221
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   222
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   223
sub Char
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   224
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   225
    my ($self, $checker, $str) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   226
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   227
    # Inform the checker that this might be insignificant whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   228
    $checker->isWS ($str);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   229
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   230
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   231
package XML::Checker::Context::Mixed;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   232
use vars qw( @ISA );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   233
@ISA = qw( XML::Checker::Context );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   234
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   235
sub new
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   236
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   237
    my ($class, $rule) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   238
    bless { Name => $rule->{Name}, N => 0 }, $class;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   239
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   240
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   241
sub debug
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   242
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   243
    my $self = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   244
    "Context::Mixed[Name=" . $self->{Name} . ",N=" , $self->{N} . "]";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   245
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   246
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   247
sub Start
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   248
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   249
    my ($self, $checker, $tag) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   250
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   251
    $checker->fail (157, "unexpected Element [$tag]",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   252
		    ChildElementIndex => $self->{N})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   253
	unless exists $self->{Name}->{$tag};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   254
    $self->{N}++;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   255
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   256
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   257
package XML::Checker::ERule;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   258
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   259
package XML::Checker::ERule::EMPTY;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   260
use vars qw( @ISA );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   261
@ISA = qw( XML::Checker::ERule );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   262
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   263
sub new
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   264
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   265
    my ($class) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   266
    bless {}, $class;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   267
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   268
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   269
my $context = new XML::Checker::Context::EMPTY;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   270
sub context { $context }	# share the context
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   271
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   272
sub debug { "EMPTY" }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   273
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   274
package XML::Checker::ERule::ANY;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   275
use vars qw( @ISA );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   276
@ISA = qw( XML::Checker::ERule );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   277
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   278
sub new
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   279
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   280
    my ($class) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   281
    bless {}, $class;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   282
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   283
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   284
my $any_context = new XML::Checker::Context::ANY;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   285
sub context { $any_context }	# share the context
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   286
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   287
sub debug { "ANY" }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   288
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   289
package XML::Checker::ERule::Mixed;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   290
use vars qw( @ISA );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   291
@ISA = qw( XML::Checker::ERule );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   292
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   293
sub new
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   294
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   295
    my ($class) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   296
    bless { Name => {} }, $class;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   297
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   298
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   299
sub context 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   300
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   301
    my ($self) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   302
    new XML::Checker::Context::Mixed ($self);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   303
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   304
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   305
sub setModel
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   306
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   307
    my ($self, $model) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   308
    my $rule = $model;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   309
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   310
    # Mixed := '(' '#PCDATA' ')' '*'?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   311
    if ($rule =~ /^\(\s*#PCDATA\s*\)(\*)?$/)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   312
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   313
#? how do we interpret the '*' ??
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   314
         return 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   315
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   316
    else	# Mixed := '(' '#PCDATA' ('|' Name)* ')*'
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   317
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   318
	return 0 unless $rule =~ s/^\(\s*#PCDATA\s*//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   319
	return 0 unless $rule =~ s/\s*\)\*$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   320
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   321
	my %names = ();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   322
	while ($rule =~ s/^\s*\|\s*($XML::RegExp::Name)//)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   323
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   324
	    $names{$1} = 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   325
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   326
	if ($rule eq "")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   327
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   328
	    $self->{Name} = \%names;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   329
	    return 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   330
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   331
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   332
    return 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   333
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   334
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   335
sub debug
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   336
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   337
    my ($self) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   338
    "Mixed[Names=" . join("|", keys %{$self->{Name}}) . "]";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   339
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   340
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   341
package XML::Checker::ERule::Children;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   342
use vars qw( @ISA %_name %_map $_n );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   343
@ISA = qw( XML::Checker::ERule );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   344
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   345
sub new
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   346
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   347
    my ($class) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   348
    bless {}, $class;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   349
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   350
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   351
sub context 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   352
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   353
    my ($self) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   354
    new XML::Checker::Context::Children ($self);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   355
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   356
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   357
sub _add	# static
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   358
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   359
    my $exp = new XML::Checker::Term (@_);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   360
    $_map{$exp->{N}} = $exp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   361
    $exp->str;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   362
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   363
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   364
my $IDS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   365
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   366
sub _tokenize
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   367
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   368
    my ($self, $rule) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   369
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   370
    # Replace names with Terms of the form "<n#>", e.g. "<n2>".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   371
    # Lookup already used names and store new names in %_name.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   372
    # 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   373
    $$rule =~ s/($XML::RegExp::Name)(?!>)/
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   374
	if (exists $_name{$1})		# name already used?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   375
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   376
	    $_name{$1}->str;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   377
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   378
        else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   379
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   380
	    my $exp = new XML::Checker::Term (C => 'n', N => $_n++, 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   381
					      Name => $1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   382
	    $_name{$1} = $_map{$exp->{N}} = $exp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   383
	    $exp->str;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   384
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   385
    /eg;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   386
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   387
    if ($_n < length $IDS)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   388
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   389
	# Generate regular expression for the name Term, i.e.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   390
	# a single character from $IDS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   391
	my $i = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   392
	for (values %_name)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   393
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   394
	    $_->{S} = substr ($IDS, $i++, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   395
#print "tokenized " . $_->{Name} . " num=" . $_->{N} . " to " . $_->{S} . "\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   396
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   397
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   398
    else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   399
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   400
	# Generate RE, convert Term->{N} to hex string a la "(#)", 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   401
	# e.g. "(03d)". Calculate needed length of hex string first.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   402
	my $len = 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   403
	for (my $n = $_n - 1; ($n >> 4) > 0; $len++) {}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   404
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   405
	my $i = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   406
	for (values %_name)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   407
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   408
	    $_->{S} = sprintf ("(0${len}lx)", $i++);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   409
#print "tokenized " . $_->{Name} . " num=" . $_->{N} . " to " . $_->{S} . "\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   410
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   411
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   412
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   413
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   414
sub setModel
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   415
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   416
    my ($self, $rule) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   417
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   418
    local $_n = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   419
    local %_map = ();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   420
    local %_name = ();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   421
    
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   422
    $self->_tokenize (\$rule);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   423
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   424
#?? check for single name - die "!ELEMENT contents can't be just a NAME" if $rule =~ /^$XML::RegExp::Name$/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   425
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   426
    for ($rule)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   427
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   428
	my $n = 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   429
	while ($n)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   430
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   431
	    $n = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   432
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   433
	    # cp := ( name | choice | seq ) ('?' | '*' | '+')?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   434
	    $n++ while s/<[ncs](\d+)>([?*+]?)/_add
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   435
	    (C => 'a', N => $_n++, 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   436
	     S => ($_map{$1}->re . $2))/eg;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   437
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   438
	    # choice := '(' ch_l ')'
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   439
	    $n++ while s/\(\s*<[ad](\d+)>\s*\)/_add
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   440
	    (C => 'c', N => $_n++, 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   441
	     S => "(" . join ("|", $_map{$1}->rel) . ")")/eg;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   442
	
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   443
	    # ch_l := ( cp | ch_l ) '|' ( cp | ch_l )
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   444
	    $n++ while s/<[ad](\d+)>\s*\|\s*<[ad](\d+)>/_add
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   445
	    (C => 'd', N => $_n++, 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   446
	     SL => [ $_map{$1}->rel, $_map{$2}->rel ])/eg;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   447
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   448
	    # seq := '(' (seq_l ')'
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   449
	    $n++ while s/\(\s*<[at](\d+)>\s*\)/_add
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   450
	    (C => 's', N => $_n++, 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   451
	     S => "(".join("", $_map{$1}->rel).")")/eg;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   452
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   453
	    # seq_l := ( cp | seq_l ) ',' ( cp | seq_l )
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   454
	    $n++ while s/<[at](\d+)>\s*,\s*<[at](\d+)>/_add
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   455
	    (C => 't', N => $_n++, 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   456
	     SL => [ $_map{$1}->rel, $_map{$2}->rel ])/eg;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   457
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   458
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   459
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   460
    return 0 if ($rule !~ /^<a(\d+)>$/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   461
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   462
    $self->{Name} = \%_name;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   463
    $self->{RE} = $_map{$1}->re;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   464
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   465
    return 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   466
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   467
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   468
sub debug
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   469
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   470
    my ($self) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   471
    "Children[RE=" . $self->{RE} . "]";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   472
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   473
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   474
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   475
package XML::Checker::ARule;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   476
use XML::RegExp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   477
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   478
sub new
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   479
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   480
    my ($class, $elem, $checker) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   481
    bless { Elem => $elem, Checker => $checker, Required => {} }, $class;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   482
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   483
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   484
sub Attlist
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   485
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   486
    my ($self, $attr, $type, $default, $fixed, $checker) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   487
    my ($c1, $c2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   488
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   489
    if ($self->{Defined}->{$attr})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   490
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   491
	my $tag = $self->{Elem};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   492
	$self->fail ($attr, 110, "attribute [$attr] of element [$tag] already defined");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   493
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   494
    else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   495
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   496
	$self->{Defined}->{$attr} = 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   497
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   498
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   499
    if ($default =~ /^\#(REQUIRED|IMPLIED)$/)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   500
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   501
	$c1 = $1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   502
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   503
	# Keep list of all required attributes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   504
	if ($default eq '#REQUIRED')
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   505
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   506
	    $self->{Required}->{$attr} = 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   507
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   508
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   509
    else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   510
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   511
	$self->fail ($attr, 122, "invalid default attribute value [$default]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   512
	    unless $default =~ /^$XML::RegExp::AttValue$/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   513
				   
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   514
	$default = substr ($default, 1, length($default)-2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   515
	$self->{Default}->{$attr} = $default;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   516
	$c1 = 'FIXED' if $fixed;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   517
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   518
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   519
    if ($type eq 'ID')
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   520
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   521
	$self->fail ($attr, 123, "invalid default ID [$default], must be #REQUIRED or #IMPLIED")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   522
	    unless $default =~ /^#(REQUIRED|IMPLIED)$/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   523
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   524
	if (exists ($self->{ID}) && $self->{ID} ne $attr)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   525
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   526
	    $self->fail ($attr, 151, "only one ID allowed per ELEMENT " .
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   527
			 "first=[" . $self->{ID} . "]");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   528
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   529
	else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   530
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   531
	    $self->{ID} = $attr;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   532
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   533
	$c2 = 'ID';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   534
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   535
    elsif ($type =~ /^(IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS)$/)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   536
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   537
	my $def = $self->{Default}->{$attr};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   538
	if (defined $def)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   539
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   540
	    my $re = ($type =~ /^[IE]/) ? $XML::RegExp::Name : $XML::RegExp::NmToken;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   541
	    if ($type =~ /S$/)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   542
	    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   543
		for (split (/\s+/, $def))
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   544
		{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   545
		    $self->fail ($attr, 121,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   546
				 "invalid default [$_] in $type [$def]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   547
			unless $_ =~ /^$re$/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   548
		}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   549
	    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   550
	    else	# singular
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   551
	    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   552
		$self->fail ($attr, 120, "invalid default $type [$def]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   553
			unless $def =~ /^$re$/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   554
	    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   555
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   556
	$c2 = $type;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   557
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   558
    elsif ($type ne 'CDATA')	# Enumerated := NotationType | Enumeration
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   559
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   560
	if ($type =~ /^\s*NOTATION\s*\(\s*($XML::RegExp::Name(\s*\|\s*$XML::RegExp::Name)*)\s*\)\s*$/)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   561
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   562
	    $self->fail ($attr, 135, "empty NOTATION list in ATTLIST")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   563
		unless defined $1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   564
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   565
	    my @tok = split (/\s*\|\s*/, $1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   566
	    for (@tok)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   567
	    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   568
		$self->fail ($attr, 100, "undefined NOTATION [$_] in ATTLIST")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   569
			unless exists $checker->{NOTATION}->{$_};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   570
	    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   571
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   572
	    my $re = join ("|", @tok);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   573
	    $self->{NotationRE} = "^($re)\$";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   574
	    $c2 = 'NotationType';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   575
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   576
	elsif ($type =~ /^\s*\(\s*($XML::RegExp::NmToken(\s*\|\s*$XML::RegExp::NmToken)*)\s*\)\s*$/)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   577
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   578
	    # Enumeration
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   579
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   580
	    $self->fail ($attr, 136, "empty Enumeration list in ATTLIST")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   581
		    unless defined $1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   582
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   583
	    my @tok = split (/\s*\|\s*/, $1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   584
	    for (@tok)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   585
	    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   586
		$self->fail ($attr, 134,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   587
			     "invalid Enumeration value [$_] in ATTLIST")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   588
		unless $_ =~ /^$XML::RegExp::NmToken$/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   589
	    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   590
	    $self->{EnumRE}->{$attr} = '^(' . join ("|", @tok) . ')$'; #';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   591
	    $c2 = 'Enumeration';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   592
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   593
	else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   594
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   595
	    $self->fail ($attr, 137, "invalid ATTLIST type [$type]");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   596
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   597
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   598
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   599
    $self->{Check1}->{$attr} = $c1 if $c1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   600
    $self->{Check2}->{$attr} = $c2 if $c2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   601
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   602
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   603
sub fail
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   604
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   605
    my $self = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   606
    my $attr = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   607
    $self->{Checker}->fail (@_, Element => $self->{Elem}, Attr => $attr);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   608
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   609
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   610
sub check
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   611
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   612
    my ($self, $attr) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   613
    my $func1 = $self->{Check1}->{$attr};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   614
    my $func2 = $self->{Check2}->{$attr};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   615
#    print "check func1=$func1 func2=$func2 @_\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   616
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   617
    if (exists $self->{ReqNotSeen}->{$attr})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   618
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   619
	delete $self->{ReqNotSeen}->{$attr};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   620
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   621
    no strict;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   622
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   623
    &$func1 (@_) if defined $func1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   624
    &$func2 (@_) if defined $func2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   625
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   626
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   627
# Copies the list of all required attributes from $self->{Required} to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   628
# $self->{ReqNotSeen}. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   629
# When check() encounters a required attribute, it is removed from ReqNotSeen. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   630
# In EndAttr we look at which attribute names are still in ReqNotSeen - those
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   631
# are the ones that were not specified and are, therefore, in error.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   632
sub StartAttr
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   633
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   634
    my $self = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   635
    my %not_seen = %{ $self->{Required} };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   636
    $self->{ReqNotSeen} = \%not_seen;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   637
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   638
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   639
# Checks which of the #REQUIRED attributes were not specified
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   640
sub EndAttr
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   641
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   642
    my $self = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   643
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   644
    for my $attr (keys %{ $self->{ReqNotSeen} })
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   645
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   646
	$self->fail ($attr, 159, 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   647
		     "unspecified value for \#REQUIRED attribute [$attr]");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   648
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   649
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   650
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   651
sub FIXED
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   652
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   653
    my ($self, $attr, $val, $specified) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   654
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   655
    my $default = $self->{Default}->{$attr};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   656
    $self->fail ($attr, 150, 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   657
		 "bad \#FIXED attribute value [$val], it should be [$default]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   658
	unless ($val eq $default);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   659
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   660
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   661
sub IMPLIED
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   662
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   663
    my ($self, $attr, $val, $specified) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   664
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   665
#?? should #IMPLIED be specified?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   666
    $self->fail ($attr, 158, 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   667
		 "unspecified value for \#IMPLIED attribute [$attr]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   668
	unless $specified;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   669
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   670
#?? Implied handler ?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   671
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   672
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   673
# This is called when an attribute is passed to the check() method by
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   674
# XML::Checker::Attr(), i.e. when the attribute was specified explicitly
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   675
# or defaulted by the parser (which should never happen), *NOT* when the 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   676
# attribute was omitted. (The latter is checked by StartAttr/EndAttr)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   677
sub REQUIRED
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   678
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   679
    my ($self, $attr, $val, $specified) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   680
#    print "REQUIRED attr=$attr val=$val spec=$specified\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   681
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   682
    $self->fail ($attr, 159, 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   683
		 "unspecified value for \#REQUIRED attribute [$attr]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   684
	unless $specified;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   685
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   686
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   687
sub ID		# must be #IMPLIED or #REQUIRED
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   688
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   689
    my ($self, $attr, $val, $specified) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   690
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   691
    $self->fail ($attr, 131, "invalid ID [$val]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   692
	unless $val =~ /^$XML::RegExp::Name$/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   693
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   694
    $self->fail ($attr, 111, "ID [$val] already defined")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   695
	if $self->{Checker}->{ID}->{$val}++;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   696
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   697
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   698
sub IDREF
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   699
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   700
    my ($self, $attr, $val, $specified) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   701
    
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   702
    $self->fail ($attr, 132, "invalid IDREF [$val]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   703
	unless $val =~ /^$XML::RegExp::Name$/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   704
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   705
    $self->{Checker}->{IDREF}->{$val}++;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   706
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   707
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   708
sub IDREFS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   709
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   710
    my ($self, $attr, $val, $specified) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   711
    for (split /\s+/, $val)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   712
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   713
	$self->IDREF ($attr, $_);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   714
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   715
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   716
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   717
sub ENTITY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   718
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   719
    my ($self, $attr, $val, $specified) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   720
#?? should it be specified?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   721
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   722
    $self->fail ($attr, 133, "invalid ENTITY name [$val]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   723
	unless $val =~ /^$XML::RegExp::Name$/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   724
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   725
    $self->fail ($attr, 102, "undefined unparsed ENTITY [$val]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   726
	unless exists $self->{Checker}->{Unparsed}->{$val};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   727
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   728
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   729
sub ENTITIES
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   730
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   731
    my ($self, $attr, $val, $specified) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   732
    for (split /\s+/, $val)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   733
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   734
	$self->ENTITY ($attr, $_);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   735
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   736
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   737
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   738
sub NMTOKEN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   739
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   740
    my ($self, $attr, $val, $specified) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   741
    $self->fail ($attr, 130, "invalid NMTOKEN [$val]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   742
	unless $val =~ /^$XML::RegExp::NmToken$/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   743
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   744
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   745
sub NMTOKENS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   746
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   747
    my ($self, $attr, $val, $specified) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   748
    for (split /\s+/, $val)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   749
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   750
	$self->NMTOKEN ($attr, $_, $specified);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   751
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   752
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   753
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   754
sub Enumeration
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   755
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   756
    my ($self, $attr, $val, $specified) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   757
    my $re = $self->{EnumRE}->{$attr};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   758
    
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   759
    $self->fail ($attr, 160, "invalid Enumeration value [$val]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   760
	unless $val =~ /$re/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   761
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   762
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   763
sub NotationType
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   764
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   765
    my ($self, $attr, $val, $specified) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   766
    my $re = $self->{NotationRE};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   767
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   768
    $self->fail ($attr, 161, "invalid NOTATION value [$val]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   769
	unless $val =~ /$re/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   770
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   771
    $self->fail ($attr, 162, "undefined NOTATION [$val]")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   772
	unless exists $self->{Checker}->{NOTATION}->{$val};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   773
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   774
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   775
package XML::Checker;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   776
use vars qw ( $VERSION $FAIL $INSIGNIF_WS );
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   777
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   778
BEGIN 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   779
{ 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   780
    $VERSION = '0.09'; 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   781
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   782
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   783
$FAIL = \&print_error;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   784
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   785
# Whether the last seen Char data was insignicant whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   786
$INSIGNIF_WS = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   787
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   788
sub new
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   789
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   790
    my ($class, %args) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   791
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   792
    $args{ERule} = {};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   793
    $args{ARule} = {};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   794
    $args{InCDATA} = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   795
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   796
#    $args{Debug} = 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   797
    bless \%args, $class;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   798
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   799
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   800
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   801
sub element_decl
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   802
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   803
    my ($self, $hash) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   804
    $self->Element ($hash->{Name}, $hash->{Model});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   805
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   806
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   807
# Same parameter order as the Element handler in XML::Parser module
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   808
sub Element
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   809
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   810
    my ($self, $name, $model) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   811
    
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   812
    if (defined $self->{ERule}->{$name})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   813
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   814
	$self->fail (115, "ELEMENT [$name] already defined",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   815
		     Element => $name);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   816
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   817
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   818
    if ($model eq "EMPTY")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   819
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   820
	$self->{ERule}->{$name} = new XML::Checker::ERule::EMPTY;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   821
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   822
    elsif ($model eq "ANY")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   823
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   824
	$self->{ERule}->{$name} = new XML::Checker::ERule::ANY;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   825
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   826
    elsif ($model =~ /#PCDATA/)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   827
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   828
        my $rule = new XML::Checker::ERule::Mixed;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   829
	if ($rule->setModel ($model))
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   830
        {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   831
	    $self->{ERule}->{$name} = $rule;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   832
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   833
        else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   834
        {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   835
	    $self->fail (124, "bad model [$model] for ELEMENT [$name]",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   836
			 Element => $name);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   837
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   838
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   839
    else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   840
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   841
        my $rule = new XML::Checker::ERule::Children;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   842
	if ($rule->setModel ($model))
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   843
        {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   844
	    $self->{ERule}->{$name} = $rule;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   845
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   846
        else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   847
        {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   848
	    $self->fail (124, "bad model [$model] for ELEMENT [$name]",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   849
			 Element => $name);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   850
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   851
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   852
    my $rule = $self->{ERule}->{$name};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   853
    print "added ELEMENT model for $name: " . $rule->debug . "\n"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   854
	   if $rule and $self->{Debug};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   855
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   856
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   857
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   858
sub attlist_decl
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   859
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   860
    my ($self, $hash) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   861
    $self->Attlist ($hash->{ElementName}, $hash->{AttributeName},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   862
		    $hash->{Type}, $hash->{Default}, $hash->{Fixed});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   863
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   864
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   865
sub Attlist
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   866
{ 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   867
    my ($self, $tag, $attrName, $type, $default, $fixed) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   868
    my $arule = $self->{ARule}->{$tag} ||= 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   869
	new XML::Checker::ARule ($tag, $self);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   870
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   871
    $arule->Attlist ($attrName, $type, $default, $fixed, $self);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   872
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   873
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   874
# Initializes the context stack to check an XML::DOM::Element
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   875
sub InitDomElem
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   876
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   877
    my $self = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   878
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   879
    # initialize Context stack
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   880
    $self->{Context} = [ new XML::Checker::Context::ANY ($self) ];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   881
    $self->{InCDATA} = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   882
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   883
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   884
# Clears the context stack after checking an XML::DOM::Element
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   885
sub FinalDomElem
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   886
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   887
    my $self = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   888
    delete $self->{Context};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   889
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   890
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   891
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   892
sub start_document
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   893
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   894
    shift->Init;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   895
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   896
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   897
sub Init
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   898
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   899
    my $self = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   900
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   901
    # initialize Context stack
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   902
    $self->{Context} = [ new XML::Checker::DocContext ($self) ];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   903
    $self->{InCDATA} = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   904
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   905
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   906
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   907
sub end_document
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   908
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   909
    shift->Final;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   910
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   911
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   912
sub Final
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   913
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   914
    my $self = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   915
#?? could add more statistics: unreferenced Unparsed, ID
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   916
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   917
    for (keys %{ $self->{IDREF} })
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   918
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   919
	my $n = $self->{IDREF}->{$_};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   920
	$self->fail (200, "undefined ID [$_] was referenced [$n] times")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   921
	    unless defined $self->{ID}->{$_};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   922
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   923
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   924
    for (keys %{ $self->{ID} })
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   925
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   926
	my $n = $self->{IDREF}->{$_} || 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   927
	$self->fail (300, "[$n] references to ID [$_]");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   928
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   929
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   930
    delete $self->{Context};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   931
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   932
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   933
sub getRootElement
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   934
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   935
    my $self = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   936
#    print "getRoot $self " . $self->{RootElement} . "\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   937
    $_[0]->{RootElement};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   938
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   939
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   940
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   941
sub doctype_decl
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   942
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   943
    my ($self, $hash) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   944
    $self->Doctype ($hash->{Name}, $hash->{SystemId},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   945
		    $hash->{PublicId}, $hash->{Internal});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   946
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   947
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   948
sub Doctype
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   949
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   950
    my ($self, $name, $sysid, $pubid, $internal) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   951
    $self->{RootElement} = $name;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   952
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   953
    my $context = $self->{Context}->[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   954
    $context->setRootElement ($name);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   955
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   956
#?? what else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   957
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   958
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   959
sub Attr
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   960
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   961
    my ($self, $tag, $attr, $val, $specified) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   962
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   963
#print "Attr for tag=$tag attr=$attr val=$val spec=$specified\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   964
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   965
    my $arule = $self->{ARule}->{$tag};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   966
    if (defined $arule && $arule->{Defined}->{$attr})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   967
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   968
	$arule->check ($attr, $val, $specified);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   969
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   970
    else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   971
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   972
	$self->fail (103, "undefined attribute [$attr]", Element => $tag);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   973
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   974
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   975
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   976
sub EndAttr
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   977
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   978
    my $self = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   979
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   980
    my $arule = $self->{CurrARule};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   981
    if (defined $arule)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   982
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   983
	$arule->EndAttr;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   984
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   985
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   986
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   987
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   988
sub start_element
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   989
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   990
    my ($self, $hash) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   991
    my $tag = $hash->{Name};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   992
    my $attr = $hash->{Attributes};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   993
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   994
    $self->Start ($tag);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   995
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   996
    if (exists $hash->{AttributeOrder})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   997
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   998
	my $defaulted = $hash->{Defaulted};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   999
	my @order = @{ $hash->{AttributeOrder} };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1000
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1001
	# Specified attributes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1002
	for (my $i = 0; $i < $defaulted; $i++)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1003
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1004
	    my $a = $order[$i];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1005
	    $self->Attr ($tag, $a, $attr->{$a}, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1006
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1007
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1008
	# Defaulted attributes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1009
	for (my $i = $defaulted; $i < @order; $i++)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1010
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1011
	    my $attr = $order[$i];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1012
	    $self->Attr ($tag, $a, $attr->{$a}, 0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1013
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1014
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1015
    else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1016
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1017
	# Assume all attributes were specified
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1018
	my @attr = %$attr;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1019
	my ($key, $val);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1020
	while ($key = shift @attr)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1021
	{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1022
	    $val = shift @attr;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1023
	    
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1024
	    $self->Attr ($tag, $key, $val, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1025
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1026
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1027
    $self->EndAttr;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1028
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1029
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1030
sub Start
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1031
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1032
    my ($self, $tag) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1033
#?? if first tag, check with root element - or does expat check this already?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1034
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1035
    my $context = $self->{Context};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1036
    $context->[0]->Start ($self, $tag);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1037
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1038
    my $erule = $self->{ERule}->{$tag};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1039
    if (defined $erule)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1040
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1041
	unshift @$context, $erule->context;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1042
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1043
    else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1044
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1045
	# It's not a real error according to the XML Spec.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1046
	$self->fail (101, "undefined ELEMENT [$tag]");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1047
	unshift @$context, new XML::Checker::Context::ANY;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1048
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1049
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1050
#?? what about ARule ??
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1051
    my $arule = $self->{ARule}->{$tag};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1052
    if (defined $arule)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1053
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1054
	$self->{CurrARule} = $arule;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1055
	$arule->StartAttr;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1056
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1057
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1058
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1059
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1060
sub end_element
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1061
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1062
    shift->End;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1063
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1064
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1065
sub End
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1066
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1067
    my ($self) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1068
    my $context = $self->{Context};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1069
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1070
    $context->[0]->End ($self);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1071
    shift @$context;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1072
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1073
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1074
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1075
sub characters
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1076
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1077
    my ($self, $hash) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1078
    my $data = $hash->{Data};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1079
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1080
    if ($self->{InCDATA})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1081
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1082
	$self->CData ($data);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1083
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1084
    else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1085
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1086
	$self->Char ($data);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1087
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1088
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1089
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1090
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1091
sub start_cdata
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1092
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1093
    $_[0]->{InCDATA} = 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1094
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1095
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1096
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1097
sub end_cdata
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1098
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1099
    $_[0]->{InCDATA} = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1100
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1101
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1102
sub Char
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1103
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1104
    my ($self, $text) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1105
    my $context = $self->{Context};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1106
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1107
    # NOTE: calls to isWS may set this to 1.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1108
    $INSIGNIF_WS = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1109
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1110
    $context->[0]->Char ($self, $text);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1111
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1112
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1113
# Treat CDATASection same as Char (Text)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1114
sub CData
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1115
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1116
    my ($self, $cdata) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1117
    my $context = $self->{Context};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1118
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1119
    $context->[0]->Char ($self, $cdata);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1120
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1121
    # CDATASection can never be insignificant whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1122
    $INSIGNIF_WS = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1123
#?? I'm not sure if this assumption is correct
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1124
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1125
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1126
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1127
sub comment
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1128
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1129
    my ($self, $hash) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1130
    $self->Comment ($hash->{Data});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1131
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1132
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1133
sub Comment
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1134
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1135
# ?? what can be checked here?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1136
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1137
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1138
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1139
sub entity_reference
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1140
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1141
    my ($self, $hash) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1142
    $self->EntityRef ($hash->{Name}, 0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1143
#?? parameter entities (like %par;) are NOT supported!
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1144
# PerlSAX::handle_default should be fixed!
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1145
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1146
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1147
sub EntityRef
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1148
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1149
    my ($self, $ref, $isParam) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1150
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1151
    if ($isParam)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1152
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1153
	# expand to "%name;"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1154
	print STDERR "XML::Checker::Entity -  parameter Entity (%ent;) not implemented\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1155
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1156
    else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1157
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1158
	# Treat same as Char - for now
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1159
	my $context = $self->{Context};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1160
	$context->[0]->Char ($self, "&$ref;");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1161
	$INSIGNIF_WS = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1162
#?? I could count the number of times each Entity is referenced
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1163
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1164
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1165
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1166
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1167
sub unparsed_entity_decl
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1168
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1169
    my ($self, $hash) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1170
    $self->Unparsed ($hash->{Name});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1171
#?? what about Base, SytemId, PublicId ?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1172
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1173
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1174
sub Unparsed
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1175
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1176
    my ($self, $entity) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1177
#    print "ARule::Unparsed $entity\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1178
    if ($self->{Unparsed}->{$entity})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1179
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1180
	$self->fail (112, "unparsed ENTITY [$entity] already defined");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1181
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1182
    else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1183
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1184
	$self->{Unparsed}->{$entity} = 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1185
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1186
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1187
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1188
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1189
sub notation_decl
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1190
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1191
    my ($self, $hash) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1192
    $self->Notation ($hash->{Name});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1193
#?? what about Base, SytemId, PublicId ?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1194
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1195
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1196
sub Notation
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1197
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1198
    my ($self, $notation) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1199
    if ($self->{NOTATION}->{$notation})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1200
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1201
	$self->fail (113, "NOTATION [$notation] already defined");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1202
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1203
    else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1204
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1205
	$self->{NOTATION}->{$notation} = 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1206
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1207
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1208
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1209
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1210
sub entity_decl
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1211
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1212
    my ($self, $hash) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1213
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1214
    $self->Entity ($hash->{Name}, $hash->{Value}, $hash->{SystemId},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1215
		   $hash->{PublicId}, $hash->{'Notation'});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1216
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1217
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1218
sub Entity
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1219
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1220
    my ($self, $name, $val, $sysId, $pubId, $ndata) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1221
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1222
    if (exists $self->{ENTITY}->{$name})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1223
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1224
	$self->fail (114, "ENTITY [$name] already defined");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1225
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1226
    else
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1227
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1228
	$self->{ENTITY}->{$name} = $val;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1229
    }    
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1230
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1231
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1232
# PerlSAX API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1233
#sub xml_decl {} $hash=> Version, Encoding, Standalone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1234
# Don't implement resolve_entity() which is called by ExternEnt!
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1235
#sub processing_instruction {} $hash=> Target, Data
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1236
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1237
# Returns whether the Char data is whitespace and also updates the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1238
# $INSIGNIF_WS variable to indicate whether it is insignificant whitespace.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1239
# Note that this method is only called in places where potential whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1240
# can be insignificant (i.e. when the ERule is Children or EMPTY)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1241
sub isWS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1242
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1243
    $INSIGNIF_WS = ($_[1] =~ /^\s*$/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1244
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1245
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1246
sub isInsignifWS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1247
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1248
    $INSIGNIF_WS;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1249
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1250
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1251
sub fail
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1252
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1253
    my $self = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1254
    &$FAIL (@_);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1255
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1256
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1257
sub print_error		# static
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1258
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1259
    my $str = error_string (@_);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1260
    print STDERR $str;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1261
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1262
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1263
sub error_string	# static
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1264
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1265
    my $code = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1266
    my $msg = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1267
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1268
    my @a = ();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1269
    my ($key, $val);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1270
    while ($key = shift)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1271
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1272
	$val = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1273
	push @a, ("$key " . (defined $val ? $val : "(undef)"));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1274
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1275
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1276
    my $cat = $code >= 200 ? ($code >= 300 ? "INFO" : "WARNING") : "ERROR";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1277
    my $str = join (", ", @a);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1278
    $str = length($str) ? "\tContext: $str\n" : "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1279
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1280
    "XML::Checker $cat-$code: $msg\n$str";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1281
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1282
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1283
sub debug
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1284
{
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1285
    my ($self) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1286
    my $context = $self->{Context}->[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1287
    my $c = $context ? $context->debug : "no context";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1288
    my $root = $self->{RootElement};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1289
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1290
    "Checker[$c,RootElement=$root]";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1291
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1292
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1293
1; # package return code
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1294
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1295
__END__
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1296
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1297
=head1 NAME
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1298
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1299
XML::Checker - A perl module for validating XML
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1300
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1301
=head1 SYNOPSIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1302
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1303
L<XML::Checker::Parser> - an L<XML::Parser> that validates at parse time
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1304
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1305
L<XML::DOM::ValParser> - an L<XML::DOM::Parser> that validates at parse time
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1306
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1307
(Some of the package names may change! This is only an alpha release...)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1308
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1309
=head1 DESCRIPTION
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1310
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1311
XML::Checker can be used in different ways to validate XML. See the manual
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1312
pages of L<XML::Checker::Parser> and L<XML::DOM::ValParser>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1313
for more information. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1314
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1315
This document only describes common topics like error handling
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1316
and the XML::Checker class itself.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1317
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1318
WARNING: Not all errors are currently checked. Almost everything is subject to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1319
change. Some reported errors may not be real errors.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1320
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1321
=head1 ERROR HANDLING
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1322
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1323
Whenever XML::Checker (or one of the packages that uses XML::Checker) detects a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1324
potential error, the 'fail handler' is called. It is currently also called 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1325
to report information, like how many times an Entity was referenced. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1326
(The whole error handling mechanism is subject to change, I'm afraid...)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1327
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1328
The default fail handler is XML::Checker::print_error(), which prints an error 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1329
message to STDERR. It does not stop the XML::Checker, so it will continue 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1330
looking for other errors. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1331
The error message is created with XML::Checker::error_string().
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1332
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1333
You can define your
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1334
own fail handler in two ways, locally and globally. Use a local variable to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1335
temporarily override the fail handler. This way the default fail handler is restored
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1336
when the local variable goes out of scope, esp. when exceptions are thrown e.g.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1337
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1338
 # Using a local variable to temporarily override the fail handler (preferred)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1339
 { # new block - start of local scope
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1340
   local $XML::Checker::FAIL = \&my_fail;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1341
   ... your code here ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1342
 } # end of block - the previous fail handler is restored
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1343
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1344
You can also set the error handler globally, risking that your code may not 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1345
be reusable or may clash with other modules that use XML::Checker.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1346
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1347
 # Globally setting the fail handler (not recommended)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1348
 $XML::Checker::FAIL = \&my_fail;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1349
 ... rest of your code ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1350
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1351
The fail handler is called with the following parameters ($code, $msg, @context), 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1352
where $code is the error code, $msg is the error description and 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1353
@context contains information on where the error occurred. The @context is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1354
a (ordered) list of (key,value) pairs and can easily be turned into a hash.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1355
It contains the following information:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1356
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1357
 Element - tag name of Element node (if applicable)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1358
 Attr - attribute name (if applicable)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1359
 ChildElementIndex - if applicable (see error 157)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1360
 line - only when parsing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1361
 column - only when parsing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1362
 byte - only when parsing (-1 means: end of file)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1363
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1364
Some examples of fail handlers:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1365
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1366
 # Don't print info messages
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1367
 sub my_fail
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1368
 {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1369
     my $code = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1370
     print STDERR XML::Checker::error_message ($code, @_)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1371
         if $code < 300;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1372
 }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1373
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1374
 # Die when the first error is encountered - this will stop
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1375
 # the parsing process. Ignore information messages.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1376
 sub my_fail
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1377
 {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1378
     my $code = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1379
     die XML::Checker::error_message ($code, @_) if $code < 300;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1380
 }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1381
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1382
 # Count the number of undefined NOTATION references
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1383
 # and print the error as usual
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1384
 sub my_fail
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1385
 {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1386
     my $code = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1387
     $count_undef_notations++ if $code == 100;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1388
     XML::Checker::print_error ($code, @_);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1389
 }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1390
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1391
 # Die when an error is encountered.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1392
 # Don't die if a warning or info message is encountered, just print a message.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1393
 sub my_fail {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1394
     my $code = shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1395
     die XML::Checker::error_string ($code, @_) if $code < 200;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1396
     XML::Checker::print_error ($code, @_);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1397
 }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1398
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1399
=head1 INSIGNIFICANT WHITESPACE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1400
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1401
XML::Checker keeps track of whether whitespace found in character data 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1402
is significant or not. It is considered insignicant if it is found inside
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1403
an element that has a ELEMENT rule that is not of type Mixed or of type ANY. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1404
(A Mixed ELEMENT rule does contains the #PCDATA keyword. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1405
An ANY rule contains the ANY keyword. See the XML spec for more info.)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1406
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1407
XML::Checker can not determine whether whitespace is insignificant in those two 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1408
cases, because they both allow regular character data to appear within
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1409
XML elements and XML::Checker can therefore not deduce whether whitespace 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1410
is part of the actual data or was just added for readability of the XML file.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1411
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1412
XML::Checker::Parser and XML::DOM::ValParser both have the option to skip
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1413
insignificant whitespace when setting B<SkipInsignifWS> to 1 in their constructor.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1414
If set, they will not call the Char handler when insignificant whitespace is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1415
encountered. This means that in XML::DOM::ValParser no Text nodes are created
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1416
for insignificant whitespace.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1417
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1418
Regardless of whether the SkipInsignifWS options is set, XML::Checker always 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1419
keeps track of whether whitespace is insignificant. After making a call to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1420
XML::Checker's Char handler, you can find out if it was insignificant whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1421
by calling the isInsignifWS method.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1422
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1423
When using multiple (nested) XML::Checker instances or when using XML::Checker
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1424
without using XML::Checker::Parser or XML::DOM::ValParser (which hardly anybody
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1425
probably will), make sure to set a local variable in the scope of your checking
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1426
code, e.g.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1427
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1428
  { # new block - start of local scope
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1429
    local $XML::Checker::INSIGNIF_WS = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1430
    ... insert your code here ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1431
  } # end of scope
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1432
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1433
=head1 ERROR CODES
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1434
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1435
There are 3 categories, errors, warnings and info messages.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1436
(The codes are still subject to change, as well the error descriptions.) 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1437
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1438
Most errors have a link to the appropriate Validaty Constraint (B<VC>)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1439
or other section in the XML specification.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1440
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1441
=head2 ERROR Messages
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1442
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1443
=head2 100 - 109
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1444
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1445
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1446
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1447
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1448
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1449
B<100> - undefined NOTATION [$notation] in ATTLIST
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1450
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1451
The ATTLIST contained a Notation reference that was not defined in a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1452
NOTATION definition. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1453
B<VC:> L<Notation Attributes|http://www.w3.org/TR/REC-xml#notatn>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1454
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1455
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1456
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1457
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1458
B<101> - undefined ELEMENT [$tagName]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1459
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1460
The specified Element was never defined in an ELEMENT definition.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1461
This is not an error according to the XML spec.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1462
See L<Element Type Declarations|http://www.w3.org/TR/REC-xml#elemdecls>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1463
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1464
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1465
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1466
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1467
B<102> - undefined unparsed ENTITY [$entity]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1468
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1469
The attribute value referenced an undefined unparsed entity.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1470
B<VC:> L<Entity Name|http://www.w3.org/TR/REC-xml#entname>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1471
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1472
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1473
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1474
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1475
B<103> - undefined attribute [$attrName]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1476
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1477
The specified attribute was not defined in an ATTLIST for that Element.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1478
B<VC:> L<Attribute Value Type|http://www.w3.org/TR/REC-xml#ValueType>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1479
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1480
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1481
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1482
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1483
=head2 110 - 119
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1484
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1485
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1486
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1487
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1488
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1489
B<110> - attribute [$attrName] of element [$tagName] already defined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1490
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1491
The specified attribute was already defined in this ATTLIST definition or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1492
in a previous one.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1493
This is not an error according to the XML spec.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1494
See L<Attribute-List Declarations|http://www.w3.org/TR/REC-xml#attdecls>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1495
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1496
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1497
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1498
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1499
B<111> - ID [$value] already defined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1500
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1501
An ID with the specified value was already defined in an attribute
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1502
within the same document.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1503
B<VC:> L<ID|http://www.w3.org/TR/REC-xml#id>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1504
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1505
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1506
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1507
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1508
B<112> - unparsed ENTITY [$entity] already defined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1509
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1510
This is not an error according to the XML spec.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1511
See L<Entity Declarations|http://www.w3.org/TR/REC-xml#sec-entity-decl>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1512
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1513
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1514
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1515
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1516
B<113> - NOTATION [$notation] already defined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1517
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1518
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1519
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1520
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1521
B<114> - ENTITY [$entity] already defined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1522
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1523
This is not an error according to the XML spec.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1524
See L<Entity Declarations|http://www.w3.org/TR/REC-xml#sec-entity-decl>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1525
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1526
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1527
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1528
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1529
B<115> - ELEMENT [$name] already defined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1530
B<VC:> L<Unique Element Type Declaration|http://www.w3.org/TR/REC-xml#EDUnique>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1531
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1532
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1533
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1534
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1535
=head2 120 - 129
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1536
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1537
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1538
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1539
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1540
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1541
B<120> - invalid default ENTITY [$default]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1542
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1543
(Or IDREF or NMTOKEN instead of ENTITY.)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1544
The ENTITY, IDREF or NMTOKEN reference in the default attribute 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1545
value for an attribute with types ENTITY, IDREF or NMTOKEN was not
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1546
valid.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1547
B<VC:> L<Attribute Default Legal|http://www.w3.org/TR/REC-xml#defattrvalid>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1548
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1549
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1550
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1551
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1552
B<121> - invalid default [$token] in ENTITIES [$default]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1553
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1554
(Or IDREFS or NMTOKENS instead of ENTITIES)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1555
One of the ENTITY, IDREF or NMTOKEN references in the default attribute 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1556
value for an attribute with types ENTITIES, IDREFS or NMTOKENS was not
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1557
valid.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1558
B<VC:> L<Attribute Default Legal|http://www.w3.org/TR/REC-xml#defattrvalid>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1559
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1560
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1561
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1562
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1563
B<122> - invalid default attribute value [$default]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1564
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1565
The specified default attribute value is not a valid attribute value.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1566
B<VC:> L<Attribute Default Legal|http://www.w3.org/TR/REC-xml#defattrvalid>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1567
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1568
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1569
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1570
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1571
B<123> - invalid default ID [$default], must be #REQUIRED or #IMPLIED
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1572
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1573
The default attribute value for an attribute of type ID has to be 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1574
#REQUIRED or #IMPLIED.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1575
B<VC:> L<ID Attribute Default|http://www.w3.org/TR/REC-xml#id-default>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1576
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1577
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1578
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1579
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1580
B<124> - bad model [$model] for ELEMENT [$name]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1581
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1582
The model in the ELEMENT definition did not conform to the XML syntax 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1583
for Mixed models.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1584
See L<Mixed Content|http://www.w3.org/TR/REC-xml#sec-mixed-content>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1585
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1586
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1587
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1588
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1589
=head2 130 - 139
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1590
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1591
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1592
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1593
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1594
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1595
B<130> - invalid NMTOKEN [$attrValue]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1596
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1597
The attribute value is not a valid NmToken token.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1598
B<VC:> L<Enumeration|http://www.w3.org/TR/REC-xml#enum>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1599
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1600
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1601
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1602
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1603
B<131> - invalid ID [$attrValue]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1604
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1605
The specified attribute value is not a valid Name token.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1606
B<VC:> L<ID|http://www.w3.org/TR/REC-xml#id>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1607
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1608
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1609
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1610
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1611
B<132> - invalid IDREF [$value]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1612
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1613
The specified attribute value is not a valid Name token.  
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1614
B<VC:> L<IDREF|http://www.w3.org/TR/REC-xml#idref>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1615
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1616
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1617
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1618
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1619
B<133> - invalid ENTITY name [$name]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1620
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1621
The specified attribute value is not a valid Name token.  
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1622
B<VC:> L<Entity Name|http://www.w3.org/TR/REC-xml#entname>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1623
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1624
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1625
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1626
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1627
B<134> - invalid Enumeration value [$value] in ATTLIST
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1628
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1629
The specified value is not a valid NmToken (see XML spec for def.)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1630
See definition of L<NmToken|http://www.w3.org/TR/REC-xml#NT-Nmtoken>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1631
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1632
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1633
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1634
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1635
B<135> - empty NOTATION list in ATTLIST
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1636
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1637
The NOTATION list of the ATTLIST definition did not contain any NOTATION
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1638
references.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1639
See definition of L<NotationType|http://www.w3.org/TR/REC-xml#NT-NotationType>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1640
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1641
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1642
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1643
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1644
B<136> - empty Enumeration list in ATTLIST
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1645
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1646
The ATTLIST definition of the attribute of type Enumeration did not
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1647
contain any values.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1648
See definition of L<Enumeration|http://www.w3.org/TR/REC-xml#NT-Enumeration>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1649
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1650
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1651
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1652
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1653
B<137> - invalid ATTLIST type [$type]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1654
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1655
The attribute type has to be one of: ID, IDREF, IDREFS, ENTITY, ENTITIES, 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1656
NMTOKEN, NMTOKENS, CDATA, NOTATION or an Enumeration.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1657
See definition of L<AttType|http://www.w3.org/TR/REC-xml#NT-AttType>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1658
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1659
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1660
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1661
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1662
=head2 150 - 159
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1663
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1664
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1665
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1666
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1667
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1668
B<150> - bad #FIXED attribute value [$value], it should be [$default]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1669
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1670
The specified attribute was defined as #FIXED in the ATTLIST definition
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1671
and the found attribute $value differs from the specified $default value.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1672
B<VC:> L<Fixed Attribute Default|http://www.w3.org/TR/REC-xml#FixedAttr>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1673
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1674
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1675
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1676
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1677
B<151> - only one ID allowed in ATTLIST per element first=[$attrName]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1678
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1679
The ATTLIST definitions for an Element may contain only one attribute
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1680
with the type ID. The specified $attrName is the one that was found first.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1681
B<VC:> L<One ID per Element Type|http://www.w3.org/TR/REC-xml#one-id-per-el>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1682
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1683
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1684
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1685
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1686
B<152> - Element should be EMPTY, found Element [$tagName]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1687
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1688
The ELEMENT definition for the specified Element said it should be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1689
EMPTY, but a child Element was found.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1690
B<VC:> L<Element Valid (sub1)|http://www.w3.org/TR/REC-xml#elementvalid>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1691
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1692
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1693
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1694
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1695
B<153> - Element should be EMPTY, found text [$text]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1696
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1697
The ELEMENT definition for the specified Element said it should be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1698
EMPTY, but text was found. Currently, whitespace is not allowed between the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1699
open and close tag. (This may be wrong, please give feedback.)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1700
To allow whitespace (subject to change), set:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1701
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1702
    $XML::Checker::Context::EMPTY::ALLOW_WHITE_SPACE = 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1703
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1704
B<VC:> L<Element Valid (sub1)|http://www.w3.org/TR/REC-xml#elementvalid>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1705
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1706
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1707
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1708
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1709
B<154> - bad order of Elements Found=[$found] RE=[$re]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1710
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1711
The child elements of the specified Element did not match the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1712
regular expression found in the ELEMENT definition. $found contains
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1713
a comma separated list of all the child element tag names that were found.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1714
$re contains the (decoded) regular expression that was used internally.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1715
B<VC:> L<Element Valid|http://www.w3.org/TR/REC-xml#elementvalid>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1716
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1717
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1718
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1719
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1720
B<155> - more than one root Element [$tags]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1721
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1722
An XML Document may only contain one Element.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1723
$tags is a comma separated list of element tag names encountered sofar.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1724
L<XML::Parser> (expat) throws 'no element found' exception.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1725
See two_roots.xml for an example.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1726
See definition of L<document|http://www.w3.org/TR/REC-xml#dt-root>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1727
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1728
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1729
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1730
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1731
B<156> - unexpected root Element [$tagName], expected [$rootTagName]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1732
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1733
The tag name of the root Element of the XML Document differs from the name 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1734
specified in the DOCTYPE section.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1735
L<XML::Parser> (expat) throws 'not well-formed' exception.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1736
See bad_root.xml for an example.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1737
B<VC:> L<Root Element Type|http://www.w3.org/TR/REC-xml#vc-roottype>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1738
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1739
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1740
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1741
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1742
B<157> - unexpected Element [$tagName]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1743
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1744
The ELEMENT definition for the specified Element does not allow child
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1745
Elements with the specified $tagName.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1746
B<VC:> L<Element Valid|http://www.w3.org/TR/REC-xml#elementvalid>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1747
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1748
The error context contains ChildElementIndex which is the index within 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1749
its parent Element (counting only Element nodes.)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1750
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1751
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1752
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1753
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1754
B<158> - unspecified value for #IMPLIED attribute [$attrName]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1755
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1756
The ATTLIST for the specified attribute said the attribute was #IMPLIED,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1757
which means the user application should supply a value, but the attribute
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1758
value was not specified. (User applications should pass a value and set
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1759
$specified to 1 in the Attr handler.)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1760
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1761
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1762
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1763
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1764
B<159> - unspecified value for #REQUIRED attribute [$attrName]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1765
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1766
The ATTLIST for the specified attribute said the attribute was #REQUIRED,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1767
which means that a value should have been specified.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1768
B<VC:> L<Required Attribute|http://www.w3.org/TR/REC-xml#RequiredAttr>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1769
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1770
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1771
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1772
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1773
=head2 160 - 169
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1774
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1775
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1776
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1777
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1778
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1779
B<160> - invalid Enumeration value [$attrValue]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1780
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1781
The specified attribute value does not match one of the Enumeration values
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1782
in the ATTLIST.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1783
B<VC:> L<Enumeration|http://www.w3.org/TR/REC-xml#enum>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1784
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1785
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1786
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1787
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1788
B<161> - invalid NOTATION value [$attrValue]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1789
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1790
The specifed attribute value was not found in the list of possible NOTATION 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1791
references as found in the ATTLIST definition.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1792
B<VC:> L<Notation Attributes|http://www.w3.org/TR/REC-xml#notatn>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1793
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1794
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1795
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1796
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1797
B<162> - undefined NOTATION [$attrValue]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1798
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1799
The NOTATION referenced by the specified attribute value was not defined.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1800
B<VC:> L<Notation Attributes|http://www.w3.org/TR/REC-xml#notatn>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1801
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1802
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1803
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1804
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1805
=head2 WARNING Messages (200 and up)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1806
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1807
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1808
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1809
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1810
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1811
B<200> - undefined ID [$id] was referenced [$n] times
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1812
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1813
The specified ID was referenced $n times, but never defined in an attribute
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1814
value with type ID.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1815
B<VC:> L<IDREF|http://www.w3.org/TR/REC-xml#idref>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1816
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1817
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1818
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1819
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1820
=head2 INFO Messages (300 and up)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1821
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1822
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1823
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1824
=item *
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1825
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1826
B<300> - [$n] references to ID [$id]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1827
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1828
The specified ID was referenced $n times.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1829
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1830
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1831
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1832
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1833
=head2 Not checked
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1834
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1835
The following errors are already checked by L<XML::Parser> (expat) and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1836
are currently not checked by XML::Checker:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1837
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1838
(?? TODO - add more info)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1839
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1840
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1841
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1842
=item root element is missing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1843
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1844
L<XML::Parser> (expat) throws 'no element found' exception. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1845
See no_root.xml for an example.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1846
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1847
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1848
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1849
=head1 XML::Checker
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1850
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1851
XML::Checker can be easily plugged into your application. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1852
It uses mostly the same style of event handlers (or callbacks) as L<XML::Parser>.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1853
See L<XML::Parser> manual page for descriptions of most handlers. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1854
 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1855
It also implements PerlSAX style event handlers. See L<PerlSAX interface>.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1856
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1857
Currently, the XML::Checker object is a blessed hash with the following 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1858
(potentially useful) entries:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1859
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1860
 $checker->{RootElement} - root element name as found in the DOCTYPE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1861
 $checker->{NOTATION}->{$notation} - is 1 if the NOTATION was defined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1862
 $checker->{ENTITY}->{$name} - contains the (first) ENTITY value if defined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1863
 $checker->{Unparsed}->{$entity} - is 1 if the unparsed ENTITY was defined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1864
 $checker->{ID}->{$id} - is 1 if the ID was defined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1865
 $checker->{IDREF}->{$id} - number of times the ID was referenced
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1866
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1867
 # Less useful:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1868
 $checker->{ERule}->{$tag} - the ELEMENT rules by Element tag name
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1869
 $checker->{ARule}->{$tag} - the ATTLIST rules by Element tag name
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1870
 $checker->{Context} - context stack used internally
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1871
 $checker->{CurrARule} - current ATTLIST rule for the current Element
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1872
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1873
=head2 XML:Checker methods
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1874
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1875
This section is only interesting when using XML::Checker directly.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1876
XML::Checker supports most event handlers that L<XML::Parser> supports with minor 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1877
differences. Note that the XML::Checker event handler methods are 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1878
instance methods and not static, so don't forget to call them like this,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1879
without passing $expat (as in the L<XML::Parser>) handlers:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1880
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1881
 $checker->Start($tagName);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1882
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1883
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1884
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1885
=item Constructor
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1886
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1887
 $checker = new XML::Checker;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1888
 $checker = new XML::Checker (%user_args);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1889
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1890
User data may be stored by client applications. Only $checker->{User} is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1891
guaranteed not to clash with internal hash keys.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1892
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1893
=item getRootElement ()
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1894
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1895
 $tagName = $checker->getRootElement;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1896
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1897
Returns the root element name as found in the DOCTYPE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1898
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1899
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1900
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1901
=head2 Expat interface
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1902
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1903
XML::Checker supports what I call the I<Expat> interface, which is 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1904
the collection of methods you normally specify as the callback handlers
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1905
when using XML::Parser.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1906
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1907
Only the following L<XML::Parser> handlers are currently supported:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1908
Init, Final, Char, Start, End, Element, Attlist, Doctype,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1909
Unparsed, Entity, Notation. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1910
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1911
I don't know how to correctly support the Default handler for all L<XML::Parser>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1912
releases. The Start handler works a little different (see below) and I
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1913
added Attr, InitDomElem, FinalDomElem, CDATA and EntityRef handlers.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1914
See L<XML::Parser> for a description of the handlers that are not listed below.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1915
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1916
Note that this interface may disappear, when the PerlSAX interface stabilizes.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1917
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1918
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1919
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1920
=item Start ($tag)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1921
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1922
 $checker->Start($tag);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1923
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1924
Call this when an Element with the specified $tag name is encountered.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1925
Different from the Start handler in L<XML::Parser>, in that no attributes 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1926
are passed in (use the Attr handler for those.)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1927
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1928
=item Attr ($tag, $attrName, $attrValue, $isSpecified)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1929
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1930
 $checker->Attr($tag,$attrName,$attrValue,$spec);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1931
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1932
Checks an attribute with the specified $attrName and $attrValue against the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1933
ATTLIST definition of the element with the specified $tag name.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1934
$isSpecified means whether the attribute was specified (1) or defaulted (0).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1935
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1936
=item EndAttr ()
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1937
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1938
 $checker->EndAttr;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1939
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1940
This should be called after all attributes are passed with Attr().
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1941
It will check which of the #REQUIRED attributes were not specified and generate
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1942
the appropriate error (159) for each one that is missing.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1943
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1944
=item CDATA ($text)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1945
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1946
 $checker->CDATA($text);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1947
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1948
This should be called whenever CDATASections are encountered.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1949
Similar to Char handler (but might perform different checks later...)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1950
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1951
=item EntityRef ($entity, $isParameterEntity)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1952
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1953
 $checker->EntityRef($entity,$isParameterEntity);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1954
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1955
Checks the ENTITY reference. Set $isParameterEntity to 1 for 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1956
entity references that start with '%'.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1957
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1958
=item InitDomElem () and FinalDomElem ()
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1959
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1960
Used by XML::DOM::Element::check() to initialize (and cleanup) the 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1961
context stack when checking a single element.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1962
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1963
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1964
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1965
=head2 PerlSAX interface
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1966
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1967
XML::Checker now also supports the PerlSAX interface, so you can use XML::Checker
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1968
wherever you use PerlSAX handlers.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1969
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1970
XML::Checker implements the following methods: start_document, end_document,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1971
start_element, end_element, characters, processing_instruction, comment,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1972
start_cdata, end_cdata, entity_reference, notation_decl, unparsed_entity_decl,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1973
entity_decl, element_decl, attlist_decl, doctype_decl, xml_decl
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1974
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1975
Not implemented: set_document_locator, ignorable_whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1976
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1977
See PerlSAX.pod for details. (It is called lib/PerlSAX.pod in the libxml-perl 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1978
distribution which can be found at CPAN.)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1979
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1980
=head1 CAVEATS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1981
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1982
This is an alpha release. Almost everything is subject to change.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1983
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1984
=head1 AUTHOR
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1985
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1986
Send bug reports, hints, tips, suggestions to Enno Derksen at
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1987
<F<enno@att.com>>. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1988
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1989
=head1 SEE ALSO
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1990
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1991
The home page of XML::Checker at L<http://www.erols.com/enno/checker/index.html>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1992
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1993
The XML spec (Extensible Markup Language 1.0) at L<http://www.w3.org/TR/REC-xml>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1994
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1995
The L<XML::Parser> and L<XML::Parser::Expat> manual pages.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1996
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1997
The other packages that come with XML::Checker: 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1998
L<XML::Checker::Parser>, L<XML::DOM::ValParser>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1999
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2000
The DOM Level 1 specification at L<http://www.w3.org/TR/REC-DOM-Level-1>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2001
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2002
The PerlSAX specification. It is currently in lib/PerlSAX.pod in the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2003
libxml-perl distribution by Ken MacLeod. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2004
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2005
The original SAX specification (Simple API for XML) can be found at 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2006
L<http://www.megginson.com/SAX> and L<http://www.megginson.com/SAX/SAX2>