| 1 |
wakaba |
1.1 |
|
| 2 |
|
|
=head1 NAME
|
| 3 |
|
|
|
| 4 |
|
|
SuikaWiki::Markup::XML::Error --- SuikaWiki XML: Error handling module for SuikaWiki::Markup::XML::*
|
| 5 |
|
|
|
| 6 |
|
|
=head1 DESCRIPTION
|
| 7 |
|
|
|
| 8 |
wakaba |
1.3 |
This module provides the common error and/or warning handling interface
|
| 9 |
|
|
for the SuikaWiki::Markup::XML::* modules. With this module, proper error
|
| 10 |
|
|
recovering and proper message outputing (eg. output as HTML element,
|
| 11 |
|
|
localized message, etc.) is easily implementable.
|
| 12 |
|
|
|
| 13 |
wakaba |
1.1 |
This module is part of SuikaWiki XML support.
|
| 14 |
|
|
|
| 15 |
|
|
=cut
|
| 16 |
|
|
|
| 17 |
|
|
package SuikaWiki::Markup::XML::Error;
|
| 18 |
|
|
use strict;
|
| 19 |
wakaba |
1.5 |
our $VERSION = do{my @r=(q$Revision: 1.4 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
|
| 20 |
wakaba |
1.3 |
|
| 21 |
|
|
## Prefixes:
|
| 22 |
|
|
## - 'SYNTAX_': don't match with XML 1.0 EBNF rules
|
| 23 |
|
|
## - 'WFC_': violation of well-formedness constraint (fatal error)
|
| 24 |
|
|
## - 'VC_': violation of validity constraint (error)
|
| 25 |
|
|
## - 'NC_': violation of namespace constraint (error)
|
| 26 |
|
|
## - 'NS_SYNTAX_': don't match with XML Namespace 1.0 EBNF rules (error)
|
| 27 |
|
|
## - 'FATAL_ERR_': fatal error specified by XML 1.0 spec
|
| 28 |
|
|
## - 'ERR_': error specified by XML 1.0 spec
|
| 29 |
|
|
## - 'WARN_': don't fullfil XML spec's or implementor's recommendation
|
| 30 |
|
|
|
| 31 |
|
|
## Error levels:
|
| 32 |
|
|
## - wfc: well-formedness (including syntax error)
|
| 33 |
|
|
## - vc: validity
|
| 34 |
|
|
## - nswfc: namespace well-formedness
|
| 35 |
|
|
## - nsvc: namespace validity
|
| 36 |
|
|
## - fatal: fatal error
|
| 37 |
|
|
## - warn: warning
|
| 38 |
wakaba |
1.1 |
|
| 39 |
|
|
my %_Error = (
|
| 40 |
wakaba |
1.3 |
## Forward compatibility error
|
| 41 |
|
|
SYNTAX_UNSUPPORTED_XML_VERSION => {
|
| 42 |
|
|
description => 'Unsupported XML version (%s)',
|
| 43 |
|
|
level => 'wfc',
|
| 44 |
|
|
},
|
| 45 |
wakaba |
1.1 |
## Syntax errors
|
| 46 |
wakaba |
1.5 |
SYNTAX_ATTR_LITERAL_NOT_FOUND => {
|
| 47 |
|
|
description => 'Attribute value literal of the attribute (name = %s) is expected',
|
| 48 |
|
|
level => 'wfc',
|
| 49 |
|
|
},
|
| 50 |
|
|
SYNTAX_ATTR_NAME_OMITTED => {
|
| 51 |
|
|
description => 'Attribute name corresponding to the value (%s) must be specified in XML',
|
| 52 |
|
|
level => 'wfc',
|
| 53 |
|
|
},
|
| 54 |
wakaba |
1.1 |
SYNTAX_DATA_OUT_OF_ROOT_ELEMENT => {
|
| 55 |
|
|
description => 'Invalid data or markup out of root element',
|
| 56 |
|
|
level => 'wfc',
|
| 57 |
|
|
},
|
| 58 |
wakaba |
1.4 |
SYNTAX_DOCTYPE_NAME_NOT_FOUND => {
|
| 59 |
|
|
description => 'Document type name must be specified in the document type declaration',
|
| 60 |
|
|
level => 'wfc',
|
| 61 |
|
|
},
|
| 62 |
|
|
SYNTAX_DOCTYPE_PID_LITERAL_NOT_FOUND => {
|
| 63 |
|
|
description => 'Minimum literal for the public identifier must follow the keyword PUBLIC',
|
| 64 |
|
|
level => 'wfc',
|
| 65 |
|
|
},
|
| 66 |
|
|
SYNTAX_DOCTYPE_SYSID_LITERAL_NOT_FOUND => {
|
| 67 |
|
|
description => 'Literal of the system identifier must follow the keyword SYSTEM or the minimum literal of the public identifier in XML',
|
| 68 |
|
|
level => 'wfc',
|
| 69 |
|
|
},
|
| 70 |
wakaba |
1.1 |
SYNTAX_END_OF_MARKUP_NOT_FOUND => {
|
| 71 |
|
|
description => sub {
|
| 72 |
|
|
my ($o, $err) = @_;
|
| 73 |
|
|
my $o_start = $err->{t}->flag ('p_o_start');
|
| 74 |
|
|
my $r = $err->{t}->qname;
|
| 75 |
|
|
$r = sprintf 'line %d, position %d%s', $o_start->{line},
|
| 76 |
|
|
$o_start->{pos}, ($r ? '; '.$r : '') if ref $o_start;
|
| 77 |
|
|
$r ? $r = '; '.$r : 0;
|
| 78 |
|
|
$err->{t} = $err->{t}->node_type;
|
| 79 |
|
|
'Markup is not closed (%s'.$r.')';
|
| 80 |
|
|
},
|
| 81 |
|
|
level => 'wfc',
|
| 82 |
|
|
},
|
| 83 |
|
|
SYNTAX_END_TAG_NOT_FOUND => {
|
| 84 |
|
|
description => sub {
|
| 85 |
|
|
my ($o, $err) = @_;
|
| 86 |
|
|
my $o_start = $err->{t}->flag ('p_o_start');
|
| 87 |
|
|
my $r = '';
|
| 88 |
|
|
$r = sprintf 'line %d, position %d%s', $o_start->{line},
|
| 89 |
|
|
$o_start->{pos}, ($r ? '; '.$r : '') if ref $o_start;
|
| 90 |
|
|
$r ? $r = '; '.$r : 0;
|
| 91 |
|
|
$err->{t} = $err->{t}->qname;
|
| 92 |
|
|
'End tag of element (type = %s'.$r.') not found';
|
| 93 |
|
|
},
|
| 94 |
|
|
level => 'wfc',
|
| 95 |
|
|
},
|
| 96 |
|
|
SYNTAX_INVALID => {
|
| 97 |
|
|
description => 'This type of markup (%s) cannot appear here',
|
| 98 |
|
|
level => 'wfc',
|
| 99 |
|
|
},
|
| 100 |
|
|
SYNTAX_INVALID_CHAR => {
|
| 101 |
|
|
description => 'Invalid character (%s) at this context',
|
| 102 |
|
|
level => 'wfc',
|
| 103 |
|
|
},
|
| 104 |
|
|
SYNTAX_INVALID_DOCTYPE_POSITION => {
|
| 105 |
|
|
description => 'DOCTYPE declaration must be between xml declaration and the root element',
|
| 106 |
|
|
level => 'wfc',
|
| 107 |
|
|
},
|
| 108 |
|
|
SYNTAX_INVALID_KEYWORD => {
|
| 109 |
|
|
description => 'Invalid keyword (%s) at this context',
|
| 110 |
|
|
level => 'wfc',
|
| 111 |
|
|
},
|
| 112 |
|
|
SYNTAX_INVALID_LITERAL => {
|
| 113 |
|
|
description => 'Literal cannot be here ("%s")',
|
| 114 |
|
|
level => 'wfc',
|
| 115 |
|
|
},
|
| 116 |
|
|
SYNTAX_INVALID_MD => {
|
| 117 |
|
|
description => 'Invalid syntax of markup declaration',
|
| 118 |
|
|
level => 'wfc',
|
| 119 |
|
|
},
|
| 120 |
|
|
SYNTAX_INVALID_POSITION => {
|
| 121 |
|
|
description => sub {
|
| 122 |
|
|
my ($o) = shift;
|
| 123 |
|
|
'This type of markup (%s) cannot be used '.({
|
| 124 |
|
|
document_entity => 'out of DTD',
|
| 125 |
|
|
dtd_internal_subset => 'in the internal subset of DTD',
|
| 126 |
|
|
dtd_external_subset => 'in the external subset of DTD',
|
| 127 |
|
|
external_parsed_entity => 'in the external parsed entity',
|
| 128 |
|
|
general_external_parsed_entity => 'in the general external parsed entity',
|
| 129 |
|
|
}->{$o->{entity_type}||'document_entity'}||'in '.$o->{entity_type})},
|
| 130 |
|
|
level => 'wfc',
|
| 131 |
|
|
},
|
| 132 |
wakaba |
1.3 |
SYNTAX_INVALID_PUBID => {
|
| 133 |
|
|
description => 'This public identifier contains at least one invalid character (%s)',
|
| 134 |
|
|
level => 'wfc',
|
| 135 |
|
|
},
|
| 136 |
wakaba |
1.1 |
SYNTAX_LEGAL_CHARACTER => {
|
| 137 |
|
|
description => sub {
|
| 138 |
|
|
my $r = sprintf 'The character U-%08X is not a legal XML Char',
|
| 139 |
|
|
$_[1]->{t};
|
| 140 |
|
|
$_[1]->{t} = undef;
|
| 141 |
|
|
$r;
|
| 142 |
|
|
},
|
| 143 |
|
|
level => 'wfc',
|
| 144 |
|
|
},
|
| 145 |
|
|
SYNTAX_MD_NAME_NOT_FOUND => {
|
| 146 |
|
|
description => 'Name is required by this type of declaration',
|
| 147 |
|
|
level => 'wfc',
|
| 148 |
|
|
},
|
| 149 |
|
|
SYNTAX_MD_SYSID_NOT_FOUND => {
|
| 150 |
|
|
description => 'System identifier is required by this type of declaration',
|
| 151 |
|
|
level => 'wfc',
|
| 152 |
|
|
},
|
| 153 |
wakaba |
1.4 |
SYNTAX_MS_IN_INTERNAL_SUBSET => {
|
| 154 |
|
|
description => 'Marked section cannot be used in the internal subset of the DTD in XML',
|
| 155 |
|
|
level => 'wfc',
|
| 156 |
|
|
},
|
| 157 |
|
|
SYNTAX_MS_INVALID_STATUS_STRING => {
|
| 158 |
|
|
description => 'Invalid string in the status keyword list',
|
| 159 |
|
|
level => 'wfc',
|
| 160 |
|
|
},
|
| 161 |
|
|
SYNTAX_MS_MULTIPLE_STATUS => {
|
| 162 |
|
|
description => 'Multiple status keyword (%s) cannot be used',
|
| 163 |
|
|
level => 'wfc',
|
| 164 |
|
|
},
|
| 165 |
|
|
SYNTAX_MS_NO_STATUS_KEYWORD => {
|
| 166 |
|
|
description => 'No status keyword found',
|
| 167 |
|
|
level => 'wfc',
|
| 168 |
|
|
},
|
| 169 |
|
|
SYNTAX_MS_NON_XML_STATUS => {
|
| 170 |
|
|
description => 'This status keyword (%s) cannot be used in XML',
|
| 171 |
|
|
level => 'wfc',
|
| 172 |
|
|
},
|
| 173 |
|
|
SYNTAX_MS_UNKNOWN_STATUS => {
|
| 174 |
|
|
description => 'Unknown status keyword (%s) is used',
|
| 175 |
|
|
level => 'wfc',
|
| 176 |
|
|
},
|
| 177 |
wakaba |
1.1 |
SYNTAX_PE_NDATA => {
|
| 178 |
|
|
description => 'Parameter entity must be a parsed entity',
|
| 179 |
|
|
level => 'wfc',
|
| 180 |
|
|
},
|
| 181 |
wakaba |
1.4 |
SYNTAX_ROOT_ELEMENT_NOT_FOUND => {
|
| 182 |
|
|
description => 'There is no root element (type = %s) in this document entity',
|
| 183 |
|
|
level => 'wfc',
|
| 184 |
|
|
},
|
| 185 |
wakaba |
1.5 |
SYNTAX_TAG_NOT_CLOSED => {
|
| 186 |
|
|
description => 'Tag must be closed in XML',
|
| 187 |
|
|
level => 'wfc',
|
| 188 |
|
|
},
|
| 189 |
wakaba |
1.1 |
SYNTAX_XML_DECLARE => {
|
| 190 |
|
|
description => 'Syntax of XML (or text) declaration is invalid',
|
| 191 |
|
|
level => 'wfc',
|
| 192 |
|
|
},
|
| 193 |
|
|
SYNTAX_XML_DECLARE_NO_ATTR => {
|
| 194 |
wakaba |
1.3 |
description => 'XML (or text) declaration has no (valid) pseudo attribute',
|
| 195 |
|
|
level => 'wfc',
|
| 196 |
|
|
},
|
| 197 |
|
|
SYNTAX_XML_DECLARE_NO_ENCODING_ATTR => {
|
| 198 |
|
|
description => q(Text declaration must have 'encoding' pseudo attribute),
|
| 199 |
|
|
level => 'wfc',
|
| 200 |
|
|
},
|
| 201 |
|
|
SYNTAX_XML_DECLARE_NO_VERSION_ATTR => {
|
| 202 |
|
|
description => q(XML declaration must have 'version' pseudo attribute),
|
| 203 |
wakaba |
1.1 |
level => 'wfc',
|
| 204 |
|
|
},
|
| 205 |
|
|
SYNTAX_XML_DECLARE_POSITION => {
|
| 206 |
|
|
description => 'XML declaration must be at the top of the entity',
|
| 207 |
|
|
level => 'wfc',
|
| 208 |
|
|
},
|
| 209 |
wakaba |
1.3 |
SYNTAX_XML_DECLARE_STANDALONE_ATTR => {
|
| 210 |
|
|
description => q(Text declaration cannot have 'standalone' pseudo attribute),
|
| 211 |
|
|
level => 'wfc',
|
| 212 |
|
|
},
|
| 213 |
wakaba |
1.1 |
## Well-formedness error
|
| 214 |
|
|
WFC_ELEMENT_TYPE_MATCH => {
|
| 215 |
|
|
description => 'End tag (type = %s) does not match with start tag (type = %s)',
|
| 216 |
|
|
level => 'wfc',
|
| 217 |
|
|
},
|
| 218 |
|
|
WFC_ENTITY_DECLARED => {
|
| 219 |
|
|
description => 'Entity (%s) must be declared before it is referred',
|
| 220 |
|
|
level => 'wfc',
|
| 221 |
|
|
},
|
| 222 |
|
|
WFC_LEGAL_CHARACTER => {
|
| 223 |
|
|
description => sub {
|
| 224 |
|
|
my $r = sprintf 'The character referred (U-%08X) is not a legal XML Char',
|
| 225 |
|
|
$_[1]->{t};
|
| 226 |
|
|
$_[1]->{t} = undef;
|
| 227 |
|
|
$r;
|
| 228 |
|
|
},
|
| 229 |
|
|
level => 'wfc',
|
| 230 |
|
|
},
|
| 231 |
|
|
WFC_NO_EXTERNAL_ENTITY_REFERENCE => {
|
| 232 |
|
|
description => 'Attribute value must not contain reference to an external entity',
|
| 233 |
|
|
level => 'wfc',
|
| 234 |
|
|
},
|
| 235 |
|
|
WFC_NO_LE_IN_ATTRIBUTE_VALUE => {
|
| 236 |
|
|
description => 'Attribute value must not contain a less-than sign (<)',
|
| 237 |
|
|
level => 'wfc',
|
| 238 |
|
|
},
|
| 239 |
|
|
WFC_NO_RECURSION => {
|
| 240 |
|
|
description => 'Parsed entity (%s) must not contain a recursive reference to itself',
|
| 241 |
|
|
level => 'wfc',
|
| 242 |
|
|
},
|
| 243 |
|
|
WFC_NO_LT_IN_ATTRIBUTE_VALUE => {
|
| 244 |
|
|
description => 'Replacement text of entity reference in an attribute value literal cannot contain LESS-THAN SIGN (<) itself',
|
| 245 |
|
|
level => 'wfc',
|
| 246 |
|
|
},
|
| 247 |
wakaba |
1.3 |
WFC_PARSED_ENTITY => {
|
| 248 |
|
|
description => 'Entity reference (%s) must not refer non-parsed entity',
|
| 249 |
|
|
level => 'wfc',
|
| 250 |
|
|
},
|
| 251 |
wakaba |
1.1 |
WFC_PE_IN_INTERNAL_SUBSET => {
|
| 252 |
|
|
description => 'Parameter entity (%s) cannot be referred in markup declaration in internal subset of DTD',
|
| 253 |
|
|
level => 'wfc',
|
| 254 |
|
|
},
|
| 255 |
|
|
WFC_UNIQUE_ATT_SPEC => {
|
| 256 |
|
|
description => 'Dupulicate attribute specification',
|
| 257 |
|
|
level => 'wfc',
|
| 258 |
|
|
},
|
| 259 |
wakaba |
1.3 |
FATAL_ERR_DECODE_IMPL_ERR => {
|
| 260 |
|
|
description => 'Decode error (%s)',
|
| 261 |
|
|
level => 'fatal',
|
| 262 |
|
|
},
|
| 263 |
|
|
FATAL_ERR_PREDEFINED_ENTITY => {
|
| 264 |
wakaba |
1.4 |
description => 'Predefined entity (%s := %s) must be declared as of the XML specification defined',
|
| 265 |
wakaba |
1.3 |
level => 'fatal',
|
| 266 |
wakaba |
1.2 |
},
|
| 267 |
wakaba |
1.1 |
## Validity error
|
| 268 |
|
|
VC_ENTITY_DECLARED => {
|
| 269 |
|
|
description => 'Entity %s should (or must to be valid) be declared before it is referred',
|
| 270 |
|
|
level => 'vc',
|
| 271 |
|
|
},
|
| 272 |
|
|
VC_NOTATION_DECLARED => {
|
| 273 |
|
|
description => 'Notation %s should (or must to be valid) be declared',
|
| 274 |
|
|
level => 'vc',
|
| 275 |
|
|
},
|
| 276 |
wakaba |
1.4 |
VC_ROOT_ELEMENT_TYPE => {
|
| 277 |
|
|
description => 'Document type name (%s) and element type name of the root element (%s) should (or must to be valid) match',
|
| 278 |
|
|
level => 'vc',
|
| 279 |
|
|
},
|
| 280 |
wakaba |
1.1 |
VC_UNIQUE_NOTATION_NAME => {
|
| 281 |
|
|
description => 'Notation %s is already declared',
|
| 282 |
|
|
level => 'warn',
|
| 283 |
|
|
},
|
| 284 |
|
|
## Namespace well-formedness error
|
| 285 |
wakaba |
1.5 |
NS_SYNTAX_LNAME_IS_NCNAME => {
|
| 286 |
|
|
description => 'Character just after the colon (:) in QName (%s) must be one of NameStartChar in namespaced XML document',
|
| 287 |
|
|
level => 'nswfc',
|
| 288 |
|
|
},
|
| 289 |
wakaba |
1.1 |
NC_PREFIX_NOT_DEFINED => {
|
| 290 |
|
|
description => 'Undeclared namespace prefix (%s) is used',
|
| 291 |
|
|
level => 'nswfc',
|
| 292 |
|
|
},
|
| 293 |
|
|
NS_SYNTAX_NAME_IS_NCNAME => {
|
| 294 |
wakaba |
1.5 |
description => 'Name with colon (%s) cannot be used here in namespaced XML document',
|
| 295 |
wakaba |
1.1 |
level => 'nswfc',
|
| 296 |
|
|
},
|
| 297 |
wakaba |
1.5 |
NS_SYNTAX_NAME_IS_QNAME => {
|
| 298 |
|
|
description => 'Name with colon (%s) must match with QName in namespaced XML document',
|
| 299 |
|
|
level => 'nswfc',
|
| 300 |
|
|
},
|
| 301 |
|
|
NC_UNIQUE_ATT_SPEC => {
|
| 302 |
|
|
description => 'Dupulicate attribute specification (%s == <%s>:%s)',
|
| 303 |
|
|
level => 'wfc',
|
| 304 |
|
|
},
|
| 305 |
wakaba |
1.1 |
## Namespace validity error
|
| 306 |
wakaba |
1.4 |
## XML (non-fatal) error
|
| 307 |
wakaba |
1.3 |
ERR_EXT_ENTITY_NOT_FOUND => {
|
| 308 |
|
|
description => 'External entity (%s == <%s>) cannot be retrived (%s)',
|
| 309 |
|
|
level => 'vc',
|
| 310 |
|
|
},
|
| 311 |
wakaba |
1.4 |
ERR_XML_NDATA_REF_IN_ENTITY_VALUE => {
|
| 312 |
|
|
description => 'Unparsed entity (%s) cannot be referred in EntityValue',
|
| 313 |
|
|
level => 'warn', ## Was fatal error but refined by SE Errata
|
| 314 |
|
|
},
|
| 315 |
|
|
ERR_XML_SYSID_HAS_FRAGMENT => {
|
| 316 |
wakaba |
1.3 |
description => 'URI Reference converted from system identifier should not have the fragment identifier (%s)',
|
| 317 |
|
|
level => 'warn',
|
| 318 |
|
|
},
|
| 319 |
wakaba |
1.4 |
## XML warning
|
| 320 |
wakaba |
1.1 |
WARN_PREDEFINED_ENTITY_NOT_DECLARED => {
|
| 321 |
|
|
description => 'Predefined general entity (%s) should be declared before it is referred for interoperability',
|
| 322 |
|
|
level => 'warn',
|
| 323 |
|
|
},
|
| 324 |
|
|
WARN_UNICODE_COMPAT_CHARACTER => {
|
| 325 |
|
|
description => sub {
|
| 326 |
|
|
my $r = sprintf 'Use of the character U+%04X is deprecated, since it is classified as compatible character in the Unicode Standard',
|
| 327 |
|
|
$_[1]->{t};
|
| 328 |
|
|
$_[1]->{t} = undef;
|
| 329 |
|
|
$r;
|
| 330 |
|
|
},
|
| 331 |
|
|
level => 'warn',
|
| 332 |
|
|
},
|
| 333 |
|
|
WARN_UNICODE_NONCHARACTER => {
|
| 334 |
|
|
description => sub {
|
| 335 |
|
|
my $r = sprintf 'Use of the code point U+%04X is deprecated, since it is noncharacter in the Unicode Standard',
|
| 336 |
|
|
$_[1]->{t};
|
| 337 |
|
|
$_[1]->{t} = undef;
|
| 338 |
|
|
$r;
|
| 339 |
|
|
},
|
| 340 |
|
|
level => 'warn',
|
| 341 |
|
|
},
|
| 342 |
|
|
WARN_UNICODE_XML_NOT_SUITABLE_CHARACTER => {
|
| 343 |
|
|
description => sub {
|
| 344 |
|
|
my $r = sprintf 'Use of the character U+%04X is deprecated by W3C Note unicode-xml',
|
| 345 |
|
|
$_[1]->{t};
|
| 346 |
|
|
$_[1]->{t} = undef;
|
| 347 |
|
|
$r;
|
| 348 |
|
|
},
|
| 349 |
|
|
level => 'warn',
|
| 350 |
|
|
},
|
| 351 |
|
|
WARN_UNIQUE_ENTITY_NAME => {
|
| 352 |
|
|
description => 'General entity %s is already declared',
|
| 353 |
|
|
level => 'warn',
|
| 354 |
|
|
},
|
| 355 |
|
|
WARN_UNIQUE_PARAMETER_ENTITY_NAME => {
|
| 356 |
|
|
description => 'Parameter entity %s is already declared',
|
| 357 |
|
|
level => 'warn',
|
| 358 |
|
|
},
|
| 359 |
wakaba |
1.5 |
## XMLName recommendation
|
| 360 |
|
|
WARN_XML_NS_URI_IS_RELATIVE => {
|
| 361 |
|
|
description => 'URI of XML Namespace name is a relative URI',
|
| 362 |
|
|
level => 'warn',
|
| 363 |
|
|
},
|
| 364 |
wakaba |
1.3 |
## RFC 3023 'SHOULD'
|
| 365 |
|
|
WARN_MT_DTD_EXTERNAL_SUBSET => {
|
| 366 |
|
|
description => q(Media type "application/xml-dtd" SHOULD be used for the external subset of the DTD or the external parameter entity),
|
| 367 |
|
|
level => 'warn',
|
| 368 |
|
|
},
|
| 369 |
|
|
WARN_MT_EXTERNAL_GENERAL_PARSED_ENTITY => {
|
| 370 |
|
|
description => q(Media type "application/xml-external-parsed-entity" SHOULD be used for the external general parsed entity),
|
| 371 |
|
|
level => 'warn',
|
| 372 |
|
|
},
|
| 373 |
|
|
WARN_MT_XML_FOR_EXT_GENERAL_ENTITY => {
|
| 374 |
|
|
description => 'Using media type %s for external general parsed entity is now forbidden unless the entity is also well-formed as a document entity',
|
| 375 |
|
|
level => 'warn',
|
| 376 |
|
|
},
|
| 377 |
wakaba |
1.1 |
## Implementation's warning
|
| 378 |
wakaba |
1.4 |
WARN_DOCTYPE_NOT_FOUND => {
|
| 379 |
|
|
description => 'No document type definition provided for this document',
|
| 380 |
|
|
level => 'warn',
|
| 381 |
|
|
},
|
| 382 |
|
|
WARN_ENTITY_DECLARATION_NOT_PROCESSED => {
|
| 383 |
|
|
description => 'This entity declaration is not processed because unread parameter entity is referred before this declaration',
|
| 384 |
|
|
level => 'warn',
|
| 385 |
|
|
},
|
| 386 |
|
|
WARN_EXTERNALLY_DEFINED_ENTITY_REFERRED => {
|
| 387 |
|
|
description => 'The entity referred (%s) is declared in the external entity, so different groove can be constructed when external entity is not read',
|
| 388 |
|
|
level => 'warn',
|
| 389 |
|
|
},
|
| 390 |
wakaba |
1.3 |
WARN_GUESS_ENCODING_IMPL_ERR => {
|
| 391 |
|
|
description => 'Guessing encoding procedure cause some error (%s)',
|
| 392 |
|
|
level => 'warn',
|
| 393 |
|
|
},
|
| 394 |
wakaba |
1.5 |
WARN_INVALID_URI_CHAR_IN_NS_NAME => {
|
| 395 |
|
|
description => 'URI of XML Namespace name contains at least one non-URI character',
|
| 396 |
|
|
level => 'warn',
|
| 397 |
|
|
},
|
| 398 |
wakaba |
1.3 |
WARN_INVALID_URI_CHAR_IN_SYSID => {
|
| 399 |
|
|
description => 'System identifier has at least one character that is invalid as part of URI Reference (%s)',
|
| 400 |
|
|
level => 'warn',
|
| 401 |
|
|
},
|
| 402 |
|
|
WARN_MT_TEXT_XML => {
|
| 403 |
|
|
description => q(In many case, labeling with the media type "text/xml" is inappropriate. Use "application/xml" or markup language specified type instead),
|
| 404 |
|
|
level => 'warn',
|
| 405 |
|
|
},
|
| 406 |
|
|
WARN_MT_TEXT_XML_EXTERNAL_PARSED_ENTITY => {
|
| 407 |
|
|
description => q(In many case, labeling with the media type "text/xml-external-parsed-entity" is inappropriate. Use "application/xml-external-parsed-entity" instead),
|
| 408 |
|
|
level => 'warn',
|
| 409 |
|
|
},
|
| 410 |
|
|
WARN_NO_CHARSET_PARAM => { ## charset parameter is optional
|
| 411 |
|
|
description => 'Charset parameter should be specified (%s)',
|
| 412 |
|
|
level => 'warn',
|
| 413 |
|
|
},
|
| 414 |
|
|
WARN_NO_CHARSET_PARAM_FOR_TEXT => { ## charset parameter have default value of ascii
|
| 415 |
|
|
description => q(Charset parameter is not specified, so default value 'us-ascii' is assumed (%s)),
|
| 416 |
|
|
level => 'warn',
|
| 417 |
|
|
},
|
| 418 |
|
|
WARN_NO_EXPLICIT_ENCODING_INFO => { ## BOM and '<?' guessing is failed (so general encoding guess is to be called)
|
| 419 |
|
|
description => q(Neither upper level protocol nor XML's encoding declaration provide encoding scheme information (or cannot read the encoding declaration because of lack of guessability)),
|
| 420 |
|
|
level => 'warn',
|
| 421 |
|
|
},
|
| 422 |
wakaba |
1.4 |
WARN_PI_TARGET_NOTATION => {
|
| 423 |
|
|
description => 'Target name of the process instruction (%s) should be declared as a notation name to ensure interoperability',
|
| 424 |
|
|
level => 'warn',
|
| 425 |
|
|
},
|
| 426 |
|
|
WARN_PID_EMPTY => {
|
| 427 |
|
|
description => 'Public identifier is empty',
|
| 428 |
|
|
level => 'warn',
|
| 429 |
|
|
},
|
| 430 |
wakaba |
1.3 |
WARN_PID_IS_INVALID_URN => {
|
| 431 |
|
|
description => 'Public identifier (%s) seems an invalid URN',
|
| 432 |
|
|
level => 'warn',
|
| 433 |
|
|
},
|
| 434 |
|
|
WARN_PID_IS_NOT_FPI_NOR_URN => {
|
| 435 |
|
|
description => 'Public identifier (%s) should be a formal public identifier or a uniform resource name to ensure interoperability',
|
| 436 |
|
|
level => 'warn',
|
| 437 |
|
|
},
|
| 438 |
|
|
WARN_PID_IS_TOO_LONG => {
|
| 439 |
|
|
description => 'Public identifier (%s) should be shorter for interoperability',
|
| 440 |
|
|
level => 'warn',
|
| 441 |
|
|
},
|
| 442 |
|
|
WARN_PID_IS_URN_WITH_RESERVED_CHAR => {
|
| 443 |
|
|
description => 'Public identifier (%s) seems a URN and it contains one or more reserved character ("/" and/or "?") which should not be used',
|
| 444 |
|
|
level => 'warn',
|
| 445 |
|
|
},
|
| 446 |
wakaba |
1.4 |
WARN_SYSID_EMPTY => {
|
| 447 |
|
|
description => 'System identifier is empty, in most case it is wrong',
|
| 448 |
|
|
level => 'warn',
|
| 449 |
|
|
},
|
| 450 |
wakaba |
1.3 |
WARN_XML_DECLARE_NO_VERSION_ATTR => {
|
| 451 |
|
|
description => 'Text declaration does not have the version pseudo attribute',
|
| 452 |
|
|
level => 'warn',
|
| 453 |
|
|
},
|
| 454 |
wakaba |
1.1 |
## Misc
|
| 455 |
|
|
UNKNOWN => {
|
| 456 |
|
|
description => 'Unknown error',
|
| 457 |
wakaba |
1.3 |
level => 'fatal',
|
| 458 |
wakaba |
1.1 |
},
|
| 459 |
|
|
);
|
| 460 |
|
|
## TODO: error handling should be customizable (hookable) by user of this module
|
| 461 |
|
|
sub raise ($$%) {
|
| 462 |
|
|
my (undef, $o, %err) = @_;
|
| 463 |
|
|
my $error_type = $_Error{$err{type}} || $_Error{UNKNOWN};
|
| 464 |
|
|
my $error_msg = ref $error_type->{description} ? &{$error_type->{description}} ($o, \%err)
|
| 465 |
|
|
: $error_type->{description};
|
| 466 |
|
|
my @err_msg;
|
| 467 |
|
|
ref $err{t} eq 'ARRAY' ? @err_msg = @{$err{t}} : defined $err{t} ? @err_msg = $err{t} : undef;
|
| 468 |
|
|
$error_msg .= ' (%s)' if scalar (@err_msg) && ($error_msg !~ /%s/);
|
| 469 |
|
|
$error_msg = sprintf $error_msg, @err_msg;
|
| 470 |
|
|
$error_msg = "Line $o->{line}, position $o->{pos}: " . $error_msg;
|
| 471 |
|
|
$error_msg = 'Entity '.($err{entity}||$o->{entity}) . ": " . $error_msg if ($err{entity}||$o->{entity});
|
| 472 |
wakaba |
1.4 |
$error_msg = '<'.($o->{uri}) . ">: " . $error_msg ;#if defined $o->{uri};
|
| 473 |
wakaba |
1.1 |
require Carp;
|
| 474 |
|
|
Carp::carp ($error_msg);
|
| 475 |
|
|
#Carp::croak ("Line $o->{line}, position $o->{pos}: ".$error_msg);
|
| 476 |
|
|
}
|
| 477 |
|
|
|
| 478 |
|
|
=head1 LICENSE
|
| 479 |
|
|
|
| 480 |
|
|
Copyright 2003 Wakaba <[email protected]>
|
| 481 |
|
|
|
| 482 |
|
|
This program is free software; you can redistribute it and/or
|
| 483 |
|
|
modify it under the same terms as Perl itself.
|
| 484 |
|
|
|
| 485 |
|
|
=cut
|
| 486 |
|
|
|
| 487 |
wakaba |
1.5 |
1; # $Date: 2003/06/29 08:34:37 $
|