1 |
#!/usr/bin/perl |
## NOTE: This module will be renamed as Element.pm. |
2 |
## This file is automatically generated |
|
3 |
## at 2006-12-31T09:30:41+00:00, |
package Message::DOM::Element; |
|
## from file "../DOM/Element.dis", |
|
|
## module <http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#ManakaiDOM.Element>. |
|
|
## Don't edit by hand! |
|
4 |
use strict; |
use strict; |
5 |
require Message::DOM::DOMCore; |
our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
6 |
|
push our @ISA, 'Message::DOM::Node', 'Message::IF::Element'; |
7 |
require Message::DOM::Document; |
require Message::DOM::Document; |
|
require Message::DOM::TreeCore; |
|
|
require Message::Util::Error::DOMException; |
|
|
package Message::DOM::Element; |
|
|
our $VERSION = 20061231.0930; |
|
|
sub DERIVATION_EXTENSION (); |
|
|
sub DERIVATION_LIST (); |
|
|
sub DERIVATION_RESTRICTION (); |
|
|
sub DERIVATION_UNION (); |
|
|
sub AUTOLOAD { |
|
|
|
|
|
|
|
|
my $al = our $AUTOLOAD; |
|
|
$al =~ s/.+:://; |
|
|
if ({'DERIVATION_EXTENSION', |
|
|
'Message::DOM::IF::TypeInfo::DERIVATION_EXTENSION', |
|
|
'DERIVATION_LIST', |
|
|
'Message::DOM::IF::TypeInfo::DERIVATION_LIST', |
|
|
'DERIVATION_RESTRICTION', |
|
|
'Message::DOM::IF::TypeInfo::DERIVATION_RESTRICTION', |
|
|
'DERIVATION_UNION', |
|
|
'Message::DOM::IF::TypeInfo::DERIVATION_UNION'}->{$al}) { |
|
|
no strict 'refs'; |
|
|
*{$AUTOLOAD} = \&{{'DERIVATION_EXTENSION', |
|
|
'Message::DOM::IF::TypeInfo::DERIVATION_EXTENSION', |
|
|
'DERIVATION_LIST', |
|
|
'Message::DOM::IF::TypeInfo::DERIVATION_LIST', |
|
|
'DERIVATION_RESTRICTION', |
|
|
'Message::DOM::IF::TypeInfo::DERIVATION_RESTRICTION', |
|
|
'DERIVATION_UNION', |
|
|
'Message::DOM::IF::TypeInfo::DERIVATION_UNION'}->{$al}}; |
|
|
goto &{$AUTOLOAD}; |
|
|
} else { |
|
|
require Carp; |
|
|
Carp::croak (qq<Can't locate method "$AUTOLOAD">); |
|
|
} |
|
|
|
|
|
} |
|
|
sub import { |
|
8 |
|
|
9 |
|
sub ____new ($$$$$) { |
10 |
|
my $self = shift->SUPER::____new (shift); |
11 |
|
($$self->{namespace_uri}, |
12 |
|
$$self->{prefix}, |
13 |
|
$$self->{local_name}) = @_; |
14 |
|
$$self->{attributes} = {}; |
15 |
|
$$self->{child_nodes} = []; |
16 |
|
return $self; |
17 |
|
} # ____new |
18 |
|
|
19 |
|
sub AUTOLOAD { |
20 |
|
my $method_name = our $AUTOLOAD; |
21 |
|
$method_name =~ s/.*:://; |
22 |
|
return if $method_name eq 'DESTROY'; |
23 |
|
|
24 |
my $self = shift; |
if ({ |
25 |
if (@_) { |
## Read-only attributes (trivial accessors) |
26 |
local $Exporter::ExportLevel = $Exporter::ExportLevel + 1; |
namespace_uri => 1, |
27 |
$self->SUPER::import (@_); |
}->{$method_name}) { |
28 |
for (grep {not /\W/} @_) { |
no strict 'refs'; |
29 |
eval qq{$_}; |
eval qq{ |
30 |
|
sub $method_name (\$) { |
31 |
|
return \${\$_[0]}->{$method_name}; |
32 |
|
} |
33 |
|
}; |
34 |
|
goto &{ $AUTOLOAD }; |
35 |
|
} elsif ({ |
36 |
|
## Read-write attributes (DOMString, trivial accessors) |
37 |
|
manakai_base_uri => 1, |
38 |
|
}->{$method_name}) { |
39 |
|
no strict 'refs'; |
40 |
|
eval qq{ |
41 |
|
sub $method_name (\$;\$) { |
42 |
|
if (\@_ > 1) { |
43 |
|
if (\${\${\$_[0]}->{owner_document}}->{strict_error_checking} and |
44 |
|
\${\$_[0]}->{manakai_read_only}) { |
45 |
|
report Message::DOM::DOMException |
46 |
|
-object => \$_[0], |
47 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
48 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
49 |
} |
} |
50 |
} |
if (defined \$_[1]) { |
51 |
|
\${\$_[0]}->{$method_name} = ''.\$_[1]; |
52 |
} |
} else { |
53 |
our %EXPORT_TAG = ('DerivationMethods', |
delete \${\$_[0]}->{$method_name}; |
|
['DERIVATION_EXTENSION', |
|
|
'DERIVATION_LIST', |
|
|
'DERIVATION_RESTRICTION', |
|
|
'DERIVATION_UNION']); |
|
|
our @EXPORT_OK = ('DERIVATION_EXTENSION', |
|
|
'DERIVATION_LIST', |
|
|
'DERIVATION_RESTRICTION', |
|
|
'DERIVATION_UNION'); |
|
|
use Exporter; push our @ISA, 'Exporter'; |
|
|
package Message::DOM::Element::ManakaiDOMDocumentElement; |
|
|
our $VERSION = 20061231.0930; |
|
|
push @Message::DOM::Document::ManakaiDOMDocument::ISA, q<Message::DOM::Element::ManakaiDOMDocumentElement> unless Message::DOM::Document::ManakaiDOMDocument->isa (q<Message::DOM::Element::ManakaiDOMDocumentElement>); |
|
|
use Char::Class::XML 'InXMLNCNameChar10', |
|
|
'InXMLNCNameChar11', |
|
|
'InXMLNCNameStartChar11', |
|
|
'InXMLNameChar10', |
|
|
'InXMLNameChar11', |
|
|
'InXMLNameStartChar11', |
|
|
'InXML_NCNameStartChar10', |
|
|
'InXML_NameStartChar10'; |
|
|
sub create_element ($$) { |
|
|
my ($self, $tagName) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$strict = $self-> |
|
|
strict_error_checking |
|
|
; |
|
|
if ($strict) { |
|
|
my $version = $self-> |
|
|
xml_version |
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $tagName) { |
|
|
if (((not defined $version or $version eq '1.0') and |
|
|
not |
|
|
($tagName =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) |
|
|
) or |
|
|
(defined $version and $version eq '1.1' and |
|
|
not |
|
|
($tagName =~ /\A\p{InXMLNameStartChar11}\p{InXMLNameChar11}*\z/) |
|
|
)) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'INVALID_CHARACTER_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_BAD_NAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $tagName, 'http://www.w3.org/2001/04/infoset#version' => $version, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_PARAM_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$self-> |
|
|
strict_error_checking |
|
|
( |
|
|
0 |
|
|
); |
|
|
$r = $self-> |
|
|
create_element_ns |
|
|
( |
|
|
undef |
|
|
, [ |
|
|
undef |
|
|
, $tagName]); |
|
|
$self-> |
|
|
strict_error_checking |
|
|
($strict); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub create_element_ns ($$$) { |
|
|
my ($self, $namespaceURI, $qualifiedName) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) { |
|
|
require Message::DOM::DOMMain; |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#DOMNamespaceURIInputProcessor'; |
|
|
|
|
|
; |
|
|
|
|
|
$namespaceURI = undef; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
($prefix, $lname); |
|
|
if (ref $qualifiedName eq 'ARRAY') { |
|
|
($prefix, $lname) = @$qualifiedName; |
|
|
$qualifiedName = defined $prefix ? $prefix.':'.$lname : $lname; |
|
|
} else { |
|
|
($prefix, $lname) = split /:/, $qualifiedName, 2; |
|
|
($prefix, $lname) = ( |
|
|
undef |
|
|
, $prefix) unless defined $lname; |
|
|
} |
|
|
|
|
|
if ($self-> |
|
|
strict_error_checking |
|
|
) { |
|
|
my $version = $self-> |
|
|
xml_version |
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $version and $version eq '1.1') { |
|
|
unless ( |
|
|
($qualifiedName =~ /\A\p{InXMLNameStartChar11}\p{InXMLNameChar11}*\z/) |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'INVALID_CHARACTER_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_BAD_NAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $qualifiedName, 'http://www.w3.org/2001/04/infoset#version' => '1.1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLQName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
unless ( |
|
|
($qualifiedName =~ /\A\p{InXMLNCNameStartChar11}\p{InXMLNCNameChar11}*(?::\p{InXMLNCNameStartChar11}\p{InXMLNCNameChar11}*)?\z/) |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_MALFORMED_QNAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $qualifiedName, 'http://www.w3.org/2001/04/infoset#version' => '1.1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLQName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
} else { |
|
|
unless ( |
|
|
($qualifiedName =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'INVALID_CHARACTER_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_BAD_NAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $qualifiedName, 'http://www.w3.org/2001/04/infoset#version' => $version, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLQName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
unless ( |
|
|
($qualifiedName =~ /\A\p{InXML_NCNameStartChar10}\p{InXMLNCNameChar10}*(?::\p{InXML_NCNameStartChar10}\p{InXMLNCNameChar10}*)?\z/) |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_MALFORMED_QNAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $qualifiedName, 'http://www.w3.org/2001/04/infoset#version' => $version, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLQName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $prefix) { |
|
|
if (not defined $namespaceURI) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#prefix' => $prefix, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_PREFIX_WITH_NULL_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} elsif ($prefix eq 'xml' and $namespaceURI ne |
|
|
'http://www.w3.org/XML/1998/namespace' |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#namespaceName' => $namespaceURI, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_XML_WITH_OTHER_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} elsif ($prefix eq 'xmlns' and $namespaceURI ne |
|
|
'http://www.w3.org/2000/xmlns/' |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#namespaceName' => $namespaceURI, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_XMLNS_WITH_OTHER_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} elsif ($namespaceURI eq |
|
|
'http://www.w3.org/XML/1998/namespace' and |
|
|
$prefix ne 'xml') { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#prefix' => $prefix, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_OTHER_WITH_XML_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} elsif ($namespaceURI eq |
|
|
'http://www.w3.org/2000/xmlns/' and |
|
|
$prefix ne 'xmlns') { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#prefix' => $prefix, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_OTHER_WITH_XMLNS_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} |
|
|
} else { ## No prefix |
|
|
if (not defined $namespaceURI) { |
|
|
# |
|
|
} elsif ($namespaceURI eq |
|
|
'http://www.w3.org/2000/xmlns/' and |
|
|
$lname ne 'xmlns') { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#prefix' => undef, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_OTHER_WITH_XMLNS_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
if (defined $namespaceURI and $namespaceURI eq |
|
|
'http://www.w3.org/2000/xmlns/' and |
|
|
|
|
|
($qualifiedName eq 'xmlns' or |
|
|
(defined $prefix and $prefix eq 'xmlns'))) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'create_element_ns', 'http://www.w3.org/2001/04/infoset#prefix' => $prefix, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMDocumentElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'qualifiedName', 'http://www.w3.org/2001/04/infoset#localName' => $lname, 'http://www.w3.org/2001/04/infoset#namespaceName' => $namespaceURI, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_OTHER_WITH_XMLNS_URI'; |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
|
|
|
|
## -- Choose the most apppropriate class for the element |
|
|
my $class = |
|
|
'Message::DOM::Element::ManakaiDOMElement' |
|
|
; |
|
|
my $nsuri = defined $namespaceURI ? $namespaceURI : ''; |
|
|
|
|
|
## Use cases: |
|
|
## - |html5:a| element type |
|
|
## - |html5:*| element types |
|
|
A: for my $nm ( |
|
|
[$nsuri, $lname], |
|
|
[$nsuri, '*'], |
|
|
) { |
|
|
unless ($Message::DOM::Element::ElementClass |
|
|
->{$nm->[0]}->{$nm->[1]}) { |
|
|
if ($Message::Util::AutoLoad::Registry::ElementType |
|
|
->{$nm->[0]}->{$nm->[1]}) { |
|
|
eval qq{require |
|
|
$Message::Util::AutoLoad::Registry::ElementType->{ |
|
|
$nm->[0]}->{$nm->[1]}->{module}}; |
|
|
die $@ if $@; |
|
|
} |
|
|
} |
|
|
|
|
|
if ($Message::DOM::Element::ElementClass |
|
|
->{$nm->[0]}->{$nm->[1]}) { |
|
|
$class = $Message::DOM::Element::ElementClass |
|
|
->{$nm->[0]}->{$nm->[1]}; |
|
|
last A; |
|
|
} |
|
|
} # A |
|
|
|
|
|
$r = bless \{ |
|
|
|
|
|
'od' |
|
|
=> $self, |
|
|
|
|
|
'child' |
|
|
=> [], |
|
|
|
|
|
'attr' |
|
|
=> {}, |
|
|
|
|
|
'sattrs' |
|
|
=> [], |
|
|
}, $class; |
|
|
Scalar::Util::weaken ($$r->{ |
|
|
'od' |
|
|
}); |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $namespaceURI) { |
|
|
if (ref $namespaceURI eq 'SCALAR') { |
|
|
$$r->{'ns'} = $namespaceURI; |
|
|
} elsif (defined $Message::Util::ManakaiStringRef::Value{$namespaceURI}) { |
|
|
$$r->{'ns'} = $Message::Util::ManakaiStringRef::Value{$namespaceURI}; |
|
|
} else { |
|
|
require Scalar::Util; |
|
|
$$r->{'ns'} = $Message::Util::ManakaiStringRef::Value{$namespaceURI} = \($namespaceURI); |
|
|
Scalar::Util::weaken ($Message::Util::ManakaiStringRef::Value{$namespaceURI}); |
|
|
} |
|
|
} else { |
|
|
CORE::delete $$r->{'ns'}; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $prefix) { |
|
|
if (ref $prefix eq 'SCALAR') { |
|
|
$$r->{'pfx'} = $prefix; |
|
|
} elsif (defined $Message::Util::ManakaiStringRef::Value{$prefix}) { |
|
|
$$r->{'pfx'} = $Message::Util::ManakaiStringRef::Value{$prefix}; |
|
|
} else { |
|
|
require Scalar::Util; |
|
|
$$r->{'pfx'} = $Message::Util::ManakaiStringRef::Value{$prefix} = \($prefix); |
|
|
Scalar::Util::weaken ($Message::Util::ManakaiStringRef::Value{$prefix}); |
|
|
} |
|
|
} else { |
|
|
CORE::delete $$r->{'pfx'}; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $lname) { |
|
|
if (ref $lname eq 'SCALAR') { |
|
|
$$r->{'ln'} = $lname; |
|
|
} elsif (defined $Message::Util::ManakaiStringRef::Value{$lname}) { |
|
|
$$r->{'ln'} = $Message::Util::ManakaiStringRef::Value{$lname}; |
|
|
} else { |
|
|
require Scalar::Util; |
|
|
$$r->{'ln'} = $Message::Util::ManakaiStringRef::Value{$lname} = \($lname); |
|
|
Scalar::Util::weaken ($Message::Util::ManakaiStringRef::Value{$lname}); |
|
|
} |
|
|
} else { |
|
|
CORE::delete $$r->{'ln'}; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
## Default attributes |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
XDA: |
|
|
{ |
|
|
my $__cfg = $self-> |
|
|
dom_config |
|
|
; |
|
|
last XDA unless $__cfg-> |
|
|
get_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/dtd-default-attribute' |
|
|
); |
|
|
my $__doctype = $self-> |
|
|
doctype |
|
|
; |
|
|
last XDA unless defined $__doctype; |
|
|
|
|
|
my $__et = $__doctype-> |
|
|
get_element_type_definition_node |
|
|
|
|
|
($qualifiedName); |
|
|
if ($__et) { |
|
|
my $__orig_strict = $self-> |
|
|
strict_error_checking |
|
|
; |
|
|
$self-> |
|
|
strict_error_checking |
|
|
( |
|
|
0 |
|
|
); |
|
|
my %__gattr; |
|
|
my %__has_attr; |
|
|
my %__pfx_to_uri; |
|
|
my $__copy_asis = $__cfg-> |
|
|
get_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree' |
|
|
); |
|
|
$__cfg-> |
|
|
set_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree' |
|
|
=> |
|
|
1 |
|
|
); |
|
|
for my $__at (@{$__et-> |
|
|
attribute_definitions |
|
|
}) { |
|
|
my $__at_default = $__at-> |
|
|
default_type |
|
|
; |
|
|
if ($__at_default == |
|
|
4 or |
|
|
|
|
|
$__at_default == |
|
|
1 |
|
|
) { |
|
|
my ($__nn1, $__nn2) = split /:/, $__at-> |
|
|
node_name |
|
|
; |
|
|
if (defined $__nn2) { # prefixed |
|
|
if ($__nn1 eq 'xmlns') { |
|
|
## TODO: NCName check, prefix check and NSURI check |
|
|
my $__attr = $self-> |
|
|
create_attribute_ns |
|
|
|
|
|
( |
|
|
'http://www.w3.org/2000/xmlns/' |
|
|
, [$__nn1, $__nn2]); |
|
|
for my $__at_child (@{$__at-> |
|
|
child_nodes |
|
|
}) { |
|
|
$__attr-> |
|
|
append_child |
|
|
|
|
|
($__at_child-> |
|
|
clone_node |
|
|
( |
|
|
1 |
|
|
)); |
|
|
} |
|
|
$__attr-> |
|
|
manakai_attribute_type |
|
|
|
|
|
($__at-> |
|
|
declared_type |
|
|
); |
|
|
my $__nsuri = $__attr-> |
|
|
value |
|
|
; |
|
|
## TODO: Namespace well-formedness check (NSURI), v1.1 chk |
|
|
$__pfx_to_uri{$__nn2} = $__nsuri; |
|
|
$r-> |
|
|
set_attribute_node_ns |
|
|
($__attr); |
|
|
## This method changes |specified| flag |
|
|
$__attr-> |
|
|
specified |
|
|
( |
|
|
0 |
|
|
); |
|
|
$__has_attr{ |
|
|
'http://www.w3.org/2000/xmlns/' |
|
|
}->{$__nn2} = |
|
|
1 |
|
|
; |
|
|
} else { |
|
|
## TODO: NCName check |
|
|
$__gattr{$__nn1}->{$__nn2} = $__at; |
|
|
} |
|
|
} else { # no prefixed |
|
|
my $__attr; |
|
|
if ($__nn1 eq 'xmlns') { |
|
|
$__attr = $self-> |
|
|
create_attribute_ns |
|
|
|
|
|
( |
|
|
'http://www.w3.org/2000/xmlns/' |
|
|
, 'xmlns'); |
|
|
$__has_attr{ |
|
|
'http://www.w3.org/2000/xmlns/' |
|
|
}->{xmlns} = |
|
|
1 |
|
|
; |
|
|
} else { |
|
|
$__attr = $self-> |
|
|
create_attribute_ns |
|
|
|
|
|
( |
|
|
undef |
|
|
, $__nn1); |
|
|
## TODO: NCName check |
|
|
} |
|
|
for my $__at_child (@{$__at-> |
|
|
child_nodes |
|
|
}) { |
|
|
$__attr-> |
|
|
append_child |
|
|
|
|
|
($__at_child-> |
|
|
clone_node |
|
|
( |
|
|
1 |
|
|
)); |
|
|
} |
|
|
$__attr-> |
|
|
manakai_attribute_type |
|
|
|
|
|
($__at-> |
|
|
declared_type |
|
|
); |
|
|
## TODO: Namespace well-formedness check (NSURI) |
|
|
$r-> |
|
|
set_attribute_node_ns |
|
|
($__attr); |
|
|
## This method changes |specified| flag |
|
|
$__attr-> |
|
|
specified |
|
|
( |
|
|
0 |
|
|
); |
|
54 |
} |
} |
55 |
} |
} |
56 |
} # attrdefs |
return \${\$_[0]}->{$method_name}; |
57 |
for my $__pfx (keys %__gattr) { |
} |
58 |
my $__nsuri = $__pfx_to_uri{$__pfx}; |
}; |
59 |
unless (defined $__nsuri) { |
goto &{ $AUTOLOAD }; |
|
## TODO: Namespace well-formedness error |
|
|
} |
|
|
LN: for my $__ln (keys %{$__gattr{$__pfx}}) { |
|
|
if ($__has_attr{defined $__nsuri ? $__nsuri : ''}->{$__ln}) { |
|
|
## TODO: Namespace well-formedness error |
|
|
next LN; |
|
|
} |
|
|
## TODO: NCName check, prefix check and NSURI check |
|
|
my $__at = $__gattr{$__pfx}->{$__ln}; |
|
|
my $__attr = $self-> |
|
|
create_attribute_ns |
|
|
|
|
|
($__nsuri, [$__pfx, $__ln]); |
|
|
for my $__at_child (@{$__at-> |
|
|
child_nodes |
|
|
}) { |
|
|
$__attr-> |
|
|
append_child |
|
|
|
|
|
($__at_child-> |
|
|
clone_node |
|
|
( |
|
|
1 |
|
|
)); |
|
|
} |
|
|
$__attr-> |
|
|
manakai_attribute_type |
|
|
|
|
|
($__at-> |
|
|
declared_type |
|
|
); |
|
|
$r-> |
|
|
set_attribute_node_ns |
|
|
($__attr); |
|
|
## This method changes |specified| flag |
|
|
$__attr-> |
|
|
specified |
|
|
( |
|
|
0 |
|
|
); |
|
|
$__has_attr{defined $__nsuri ? $__nsuri : ''}->{$__ln} = |
|
|
1 |
|
|
; |
|
|
} # LN |
|
|
} # pfx |
|
|
$__cfg-> |
|
|
set_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree' |
|
|
=> $__copy_asis); |
|
|
$self-> |
|
|
strict_error_checking |
|
|
($__orig_strict); |
|
|
} |
|
|
} # XDA |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub create_attribute ($$) { |
|
|
my ($self, $name) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$strict = $self-> |
|
|
strict_error_checking |
|
|
; |
|
|
if ($strict) { |
|
|
my $version = $self-> |
|
|
xml_version |
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $name) { |
|
|
if (((not defined $version or $version eq '1.0') and |
|
|
not |
|
|
($name =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) |
|
|
) or |
|
|
(defined $version and $version eq '1.1' and |
|
|
not |
|
|
($name =~ /\A\p{InXMLNameStartChar11}\p{InXMLNameChar11}*\z/) |
|
|
)) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'INVALID_CHARACTER_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_BAD_NAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $name, 'http://www.w3.org/2001/04/infoset#version' => $version, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_PARAM_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$self-> |
|
|
strict_error_checking |
|
|
( |
|
|
0 |
|
|
); |
|
|
$r = $self-> |
|
|
create_attribute_ns |
|
|
( |
|
|
undef |
|
|
, [ |
|
|
undef |
|
|
, $name]); |
|
|
$self-> |
|
|
strict_error_checking |
|
|
($strict); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub create_attribute_ns ($$$) { |
|
|
my ($self, $namespaceURI, $qualifiedName) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) { |
|
|
require Message::DOM::DOMMain; |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#DOMNamespaceURIInputProcessor'; |
|
|
|
|
|
; |
|
|
|
|
|
$namespaceURI = undef; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
($prefix, $lname) = ref $qualifiedName eq 'ARRAY' |
|
|
? @$qualifiedName |
|
|
: split /:/, $qualifiedName, 2; |
|
|
($prefix, $lname) = ( |
|
|
undef |
|
|
, $prefix) unless defined $lname; |
|
|
|
|
|
## TODO: autoload |
|
|
if ((defined $namespaceURI and $namespaceURI eq |
|
|
'http://www.w3.org/XML/1998/namespace' |
|
|
) or |
|
|
($lname =~ /^xml:/)) { |
|
|
require Message::DOM::XML; |
|
|
} |
|
|
|
|
|
if ($self-> |
|
|
strict_error_checking |
|
|
) { |
|
|
my $version = $self-> |
|
|
xml_version |
|
|
; |
|
|
$qualifiedName = defined $prefix ? $prefix.':'.$lname |
|
|
: $lname; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $version and $version eq '1.1') { |
|
|
unless ( |
|
|
($qualifiedName =~ /\A\p{InXMLNameStartChar11}\p{InXMLNameChar11}*\z/) |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'INVALID_CHARACTER_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_BAD_NAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $qualifiedName, 'http://www.w3.org/2001/04/infoset#version' => '1.1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLQName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
unless ( |
|
|
($qualifiedName =~ /\A\p{InXMLNCNameStartChar11}\p{InXMLNCNameChar11}*(?::\p{InXMLNCNameStartChar11}\p{InXMLNCNameChar11}*)?\z/) |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_MALFORMED_QNAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $qualifiedName, 'http://www.w3.org/2001/04/infoset#version' => '1.1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLQName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
} else { |
|
|
unless ( |
|
|
($qualifiedName =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'INVALID_CHARACTER_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_BAD_NAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $qualifiedName, 'http://www.w3.org/2001/04/infoset#version' => $version, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLQName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
unless ( |
|
|
($qualifiedName =~ /\A\p{InXML_NCNameStartChar10}\p{InXMLNCNameChar10}*(?::\p{InXML_NCNameStartChar10}\p{InXMLNCNameChar10}*)?\z/) |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_MALFORMED_QNAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $qualifiedName, 'http://www.w3.org/2001/04/infoset#version' => $version, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLQName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $prefix) { |
|
|
if (not defined $namespaceURI) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#prefix' => $prefix, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_PREFIX_WITH_NULL_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} elsif ($prefix eq 'xml' and $namespaceURI ne |
|
|
'http://www.w3.org/XML/1998/namespace' |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#namespaceName' => $namespaceURI, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_XML_WITH_OTHER_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} elsif ($prefix eq 'xmlns' and $namespaceURI ne |
|
|
'http://www.w3.org/2000/xmlns/' |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#namespaceName' => $namespaceURI, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_XMLNS_WITH_OTHER_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} elsif ($namespaceURI eq |
|
|
'http://www.w3.org/XML/1998/namespace' and |
|
|
$prefix ne 'xml') { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#prefix' => $prefix, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_OTHER_WITH_XML_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} elsif ($namespaceURI eq |
|
|
'http://www.w3.org/2000/xmlns/' and |
|
|
$prefix ne 'xmlns') { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#prefix' => $prefix, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_OTHER_WITH_XMLNS_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} |
|
|
} else { ## No prefix |
|
|
if (not defined $namespaceURI) { |
|
|
# |
|
|
} elsif ($namespaceURI eq |
|
|
'http://www.w3.org/2000/xmlns/' and |
|
|
$lname ne 'xmlns') { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#prefix' => undef, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_OTHER_WITH_XMLNS_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
$r = bless \{ |
|
|
|
|
|
'od' |
|
|
=> $self, |
|
|
|
|
|
'child' |
|
|
=> [], |
|
|
|
|
|
'specified' |
|
|
=> 1, |
|
|
}, |
|
|
'Message::DOM::Element::ManakaiDOMAttr' |
|
|
; |
|
|
Scalar::Util::weaken ($$r->{ |
|
|
'od' |
|
|
}); |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $namespaceURI) { |
|
|
if (ref $namespaceURI eq 'SCALAR') { |
|
|
$$r->{'ns'} = $namespaceURI; |
|
|
} elsif (defined $Message::Util::ManakaiStringRef::Value{$namespaceURI}) { |
|
|
$$r->{'ns'} = $Message::Util::ManakaiStringRef::Value{$namespaceURI}; |
|
|
} else { |
|
|
require Scalar::Util; |
|
|
$$r->{'ns'} = $Message::Util::ManakaiStringRef::Value{$namespaceURI} = \($namespaceURI); |
|
|
Scalar::Util::weaken ($Message::Util::ManakaiStringRef::Value{$namespaceURI}); |
|
|
} |
|
|
} else { |
|
|
CORE::delete $$r->{'ns'}; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $prefix) { |
|
|
if (ref $prefix eq 'SCALAR') { |
|
|
$$r->{'pfx'} = $prefix; |
|
|
} elsif (defined $Message::Util::ManakaiStringRef::Value{$prefix}) { |
|
|
$$r->{'pfx'} = $Message::Util::ManakaiStringRef::Value{$prefix}; |
|
|
} else { |
|
|
require Scalar::Util; |
|
|
$$r->{'pfx'} = $Message::Util::ManakaiStringRef::Value{$prefix} = \($prefix); |
|
|
Scalar::Util::weaken ($Message::Util::ManakaiStringRef::Value{$prefix}); |
|
|
} |
|
|
} else { |
|
|
CORE::delete $$r->{'pfx'}; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $lname) { |
|
|
if (ref $lname eq 'SCALAR') { |
|
|
$$r->{'ln'} = $lname; |
|
|
} elsif (defined $Message::Util::ManakaiStringRef::Value{$lname}) { |
|
|
$$r->{'ln'} = $Message::Util::ManakaiStringRef::Value{$lname}; |
|
60 |
} else { |
} else { |
61 |
require Scalar::Util; |
require Carp; |
62 |
$$r->{'ln'} = $Message::Util::ManakaiStringRef::Value{$lname} = \($lname); |
Carp::croak (qq<Can't locate method "$AUTOLOAD">); |
|
Scalar::Util::weaken ($Message::Util::ManakaiStringRef::Value{$lname}); |
|
|
} |
|
|
} else { |
|
|
CORE::delete $$r->{'ln'}; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
## Attribute type information |
|
|
if ((defined $namespaceURI and $namespaceURI eq |
|
|
'http://www.w3.org/XML/1998/namespace' and |
|
|
|
|
|
$lname eq 'id') or |
|
|
(not defined $namespaceURI and $lname eq 'xml:id')) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
if |
|
|
($self-> |
|
|
dom_config |
|
|
|
|
|
-> |
|
|
get_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/xml-id' |
|
|
)) { |
|
|
$r-> |
|
|
manakai_attribute_type |
|
|
( |
|
|
2 |
|
|
); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
$Message::DOM::DOMFeature::ClassInfo->{q<Message::DOM::Element::ManakaiDOMDocumentElement>}->{has_feature} = {}; |
|
|
$Message::DOM::ClassPoint{q<Message::DOM::Element::ManakaiDOMDocumentElement>} = 0; |
|
|
package Message::DOM::IF::Element; |
|
|
our $VERSION = 20061231.0930; |
|
|
package Message::DOM::Element::ManakaiDOMElement; |
|
|
our $VERSION = 20061231.0930; |
|
|
push our @ISA, 'Message::DOM::TreeCore::ManakaiDOMNode', |
|
|
'Message::DOM::IF::Element', |
|
|
'Message::DOM::IF::Node'; |
|
|
use Char::Class::XML 'InXMLNCNameChar10', |
|
|
'InXMLNCNameChar11', |
|
|
'InXMLNCNameStartChar11', |
|
|
'InXMLNameChar10', |
|
|
'InXMLNameChar11', |
|
|
'InXMLNameStartChar11', |
|
|
'InXML_NCNameStartChar10', |
|
|
'InXML_NameStartChar10'; |
|
|
sub node_type ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r; |
|
|
$r = 1; |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'node_type'; |
|
|
} |
|
|
} |
|
|
sub prefix ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$v = $$self->{ |
|
|
'pfx' |
|
|
}; |
|
|
$r = defined $v ? $$v : undef; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self, $given) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$od = $self-> |
|
|
owner_document |
|
|
; |
|
|
if ($od-> |
|
|
strict_error_checking |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
my $nsuri = $$self->{ |
|
|
'ns' |
|
|
}; |
|
|
if (not defined $nsuri) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#namespaceName' => undef, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'set', 'http://www.w3.org/2001/04/infoset#prefix' => $given, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_PREFIX_WITH_NULL_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'prefix'; |
|
|
|
|
|
; |
|
|
} elsif ($$nsuri ne |
|
|
'http://www.w3.org/XML/1998/namespace' and |
|
|
|
|
|
defined $given and $given eq 'xml') { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#namespaceName' => $self->namespace_uri, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'set', 'http://www.w3.org/2001/04/infoset#prefix' => $given, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_XML_WITH_OTHER_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'prefix'; |
|
|
|
|
|
; |
|
63 |
} |
} |
64 |
my $version = $od-> |
} # AUTOLOAD |
|
xml_version |
|
|
; |
|
|
|
|
65 |
|
|
66 |
{ |
## TODO: Test for create_element_ns ('', ...) |
67 |
|
|
68 |
if |
## |Node| attributes |
|
(defined $given and $given eq '') { |
|
|
require Message::DOM::DOMMain; |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-prefix', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureNamespacePrefix'; |
|
69 |
|
|
70 |
; |
sub attributes ($) { |
71 |
undef $given; |
require Message::DOM::NamedNodeMap; |
72 |
} |
return bless \\($_[0]), 'Message::DOM::NamedNodeMap::AttrMap'; |
73 |
if (defined $given) { |
} # attributes |
|
if (($version eq '1.0' and |
|
|
not |
|
|
($given =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) |
|
|
) or |
|
|
($version eq '1.1' and |
|
|
not |
|
|
($given =~ /\A\p{InXMLNameStartChar11}\p{InXMLNameChar11}*\z/) |
|
|
)) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'INVALID_CHARACTER_ERR', 'http://www.w3.org/2001/04/infoset#name' => $given, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_BAD_NAME', 'http://www.w3.org/2001/04/infoset#version' => $version, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureNamespacePrefix', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_PARAM_NAME'; |
|
74 |
|
|
75 |
; |
sub base_uri ($) { |
76 |
} elsif (index ($given, ':') > -1) { |
my $self = $_[0]; |
77 |
|
return $$self->{manakai_base_uri} if defined $$self->{manakai_base_uri}; |
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#name' => $given, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_BAD_NCNAME', 'http://www.w3.org/2001/04/infoset#version' => $version, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureNamespacePrefix', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_PARAM_NAME'; |
|
78 |
|
|
79 |
; |
local $Error::Depth = $Error::Depth + 1; |
80 |
|
my $xb = $self->get_attribute_node_ns |
81 |
|
('http://www.w3.org/XML/1998/namespace', 'base'); |
82 |
|
unless (defined $xb) { |
83 |
|
$xb = $self->get_attribute_node_ns (undef, 'xml:base'); |
84 |
} |
} |
|
} # has prefix |
|
|
|
|
|
|
|
|
} |
|
85 |
|
|
86 |
; |
if ($xb) { |
87 |
} # strict |
my $v = $self->owner_document->implementation->create_uri_reference |
88 |
if (defined $given) { |
($xb->value); |
89 |
$$self->{ |
if (not defined $v->uri_scheme) { # Relative reference |
90 |
'pfx' |
my $xbbase = $xb->base_uri; |
91 |
} = \$given; |
if (defined $xbbase) { |
92 |
} else { |
return $v->get_absolute_reference ($xbbase)->uri_reference; |
93 |
CORE::delete $$self->{ |
} |
|
'pfx' |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
sub append_child ($$) { |
|
|
my ($self, $newChild) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$self_od = $self-> |
|
|
owner_document |
|
|
; |
|
|
if ($self_od-> |
|
|
strict_error_checking |
|
|
) { |
|
|
my $anode = $self; |
|
|
while (defined $anode) { |
|
|
if ($anode eq $newChild) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'append_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_ANCESTOR_OR_SELF', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
; |
|
94 |
} |
} |
95 |
$anode = $anode-> |
return $v->uri_reference; |
|
parent_node |
|
|
; |
|
96 |
} |
} |
|
} |
|
|
my $child_od = $newChild-> |
|
|
owner_document |
|
|
; |
|
|
my $child_nt = $newChild-> |
|
|
node_type |
|
|
; |
|
|
|
|
97 |
|
|
98 |
{ |
my $pe = $$self->{parent_node}; |
99 |
|
while (defined $pe) { |
100 |
|
my $nt = $pe->node_type; |
101 |
{ |
if ($nt == 1 or $nt == 6 or $nt == 9 or $nt == 11) { |
102 |
|
## Element, Entity, Document, or DocumentFragment |
103 |
local $Error::Depth = $Error::Depth + 1; |
return $pe->base_uri; |
104 |
|
} elsif ($nt == 5) { |
105 |
{ |
## EntityReference |
106 |
|
if ($pe->manakai_external) { |
107 |
|
return $pe->manakai_entity_base_uri; |
|
my |
|
|
$strict = $self_od-> |
|
|
strict_error_checking |
|
|
; |
|
|
|
|
|
## -- Node Type check |
|
|
my @new_child; |
|
|
if ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
1 => 1, |
|
|
4 => 1, |
|
|
7 => 1, |
|
|
8 => 1, |
|
|
}->{$child_nt}) { |
|
|
push @new_child, $newChild; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
|
unless ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
1 => 1, |
|
|
4 => 1, |
|
|
7 => 1, |
|
|
8 => 1, |
|
|
}->{$cn-> |
|
|
node_type |
|
|
}) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
108 |
} |
} |
|
push @new_child, $cn; |
|
109 |
} |
} |
110 |
} else { |
$pe = $$pe->{parent_node}; |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
111 |
} |
} |
112 |
|
return $pe->base_uri if $pe; |
113 |
|
return $$self->{owner_document}->base_uri; |
114 |
|
} # base_uri |
115 |
|
|
116 |
my $nc_parent = @new_child ? $new_child[0]-> |
sub local_name ($) { # TODO: HTML5 case |
117 |
parent_node |
return ${$_[0]}->{local_name}; |
118 |
: |
} # local_name |
|
|
|
|
undef |
|
|
; |
|
|
if ($strict) { |
|
|
## -- Wrong-document check |
|
|
unless ($self_od eq $child_od) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
119 |
|
|
120 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
sub manakai_local_name ($) { |
121 |
|
return ${$_[0]}->{local_name}; |
122 |
|
} # manakai_local_name |
123 |
|
|
124 |
|
sub namespace_uri ($); |
125 |
|
|
126 |
} |
## The tag name of the element [DOM1, DOM2]. |
127 |
|
## Same as |Element.tagName| [DOM3]. |
128 |
|
|
129 |
|
*node_name = \&tag_name; |
130 |
|
|
131 |
;} |
sub node_type () { 1 } # ELEMENT_NODE |
|
|
|
|
; |
|
|
} |
|
|
|
|
|
## -- Read-onlyness check |
|
|
if ($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
132 |
|
|
133 |
{ |
sub prefix ($;$) { |
134 |
|
## NOTE: No check for new value as Firefox doesn't do. |
135 |
local $Error::Depth = $Error::Depth - 1; |
## See <http://suika.fam.cx/gate/2005/sw/prefix>. |
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
if (@new_child) { |
|
|
if ($nc_parent and |
|
|
$nc_parent-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
136 |
|
|
137 |
; |
## NOTE: Same as trivial setter except "" -> undef |
|
} |
|
|
} |
|
|
} |
|
138 |
|
|
139 |
## -- Insert at... |
## NOTE: Same as |Attr|'s |prefix|. |
|
my $index = -1; # last |
|
140 |
|
|
141 |
|
if (@_ > 1) { |
142 |
; # FOR !tc:ForAppendChild |
if (${$_[0]}->{manakai_read_only}) { |
143 |
|
report Message::DOM::DOMException |
144 |
## -- Removes from parent |
-object => $_[0], |
145 |
if ($nc_parent) { |
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
146 |
if ($child_nt == |
-subtype => 'READ_ONLY_NODE_ERR'; |
147 |
11 |
} |
148 |
) { |
if (defined $_[1] and $_[1] ne '') { |
149 |
$$newChild->{ |
${$_[0]}->{prefix} = ''.$_[1]; |
|
'child' |
|
|
} = []; |
|
150 |
} else { |
} else { |
151 |
my $v = $$nc_parent->{ |
delete ${$_[0]}->{prefix}; |
|
'child' |
|
|
}; |
|
|
RP: for my $i (0..$#$v) { |
|
|
if ($v->[$i] eq $new_child[0]) { |
|
|
splice @$v, $i, 1, (); |
|
|
last RP; |
|
|
} |
|
|
} # RP |
|
152 |
} |
} |
153 |
} |
} |
154 |
|
return ${$_[0]}->{prefix}; |
155 |
|
} # prefix |
156 |
|
|
157 |
## -- Rewrite the |parentNode| properties |
## |Element| attributes |
|
for my $nc (@new_child) { |
|
|
$$nc->{ |
|
|
'parent' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$nc->{ |
|
|
'parent' |
|
|
}); |
|
|
} |
|
|
|
|
|
my $children = $$self->{ |
|
|
'child' |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
## -- Adds to children list |
|
|
push @$children, @new_child; |
|
|
$r = $newChild; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
158 |
|
|
159 |
|
sub manakai_base_uri ($;$); |
160 |
|
|
161 |
} |
## Defined in |HTMLElement| interface of HTML5 |
162 |
|
sub inner_html ($;$) { |
163 |
|
my $self = $_[0]; |
164 |
|
|
165 |
; |
## TODO: Setter |
166 |
|
|
167 |
|
if (${$$self->{owner_document}}->{manakai_is_html}) { |
168 |
} |
require Whatpm::HTML; |
169 |
$r} |
return ${ Whatpm::HTML->get_inner_html ($self) }; |
170 |
sub insert_before ($$;$) { |
} else { |
171 |
my ($self, $newChild, $refChild) = @_; |
## TODO: This serializer is not currenly conformant to HTML5. |
172 |
my $r; |
require Whatpm::XMLSerializer; |
173 |
|
my $r = ''; |
174 |
{ |
for (@{$self->child_nodes}) { |
175 |
|
$r .= ${ Whatpm::XMLSerializer->get_outer_xml ($_) }; |
|
my |
|
|
$self_od = $self-> |
|
|
owner_document |
|
|
; |
|
|
if ($self_od-> |
|
|
strict_error_checking |
|
|
) { |
|
|
my $anode = $self; |
|
|
while (defined $anode) { |
|
|
if ($anode eq $newChild) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_ANCESTOR_OR_SELF', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
; |
|
176 |
} |
} |
177 |
$anode = $anode-> |
return $r; |
|
parent_node |
|
|
; |
|
178 |
} |
} |
179 |
} |
} # inner_html |
|
my $child_od = $newChild-> |
|
|
owner_document |
|
|
; |
|
|
my $child_nt = $newChild-> |
|
|
node_type |
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$strict = $self_od-> |
|
|
strict_error_checking |
|
|
; |
|
|
|
|
|
## -- Node Type check |
|
|
my @new_child; |
|
|
if ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
1 => 1, |
|
|
4 => 1, |
|
|
7 => 1, |
|
|
8 => 1, |
|
|
}->{$child_nt}) { |
|
|
push @new_child, $newChild; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
|
unless ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
1 => 1, |
|
|
4 => 1, |
|
|
7 => 1, |
|
|
8 => 1, |
|
|
}->{$cn-> |
|
|
node_type |
|
|
}) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
180 |
|
|
181 |
|
sub schema_type_info ($) { |
182 |
|
require Message::DOM::TypeInfo; |
183 |
|
my $v = 0; |
184 |
|
return bless \$v, 'Message::DOM::TypeInfo'; |
185 |
|
## NOTE: Currently manakai does not support XML Schema, so it is |
186 |
|
## always a no-type |TypeInfo|. It is expected that |
187 |
|
## a future version of the implementation will return an |
188 |
|
## element type definition node that also implement the |
189 |
|
## |TypeInfo| interface when the schema language is XML DTD. |
190 |
|
} # schema_type_info |
191 |
|
|
192 |
} |
## TODO: HTML5 capitalization |
193 |
|
sub tag_name ($) { |
194 |
|
my $self = shift; |
195 |
;} |
if (defined $$self->{prefix}) { |
196 |
|
return $$self->{prefix} . ':' . $$self->{local_name}; |
|
; |
|
|
} |
|
|
push @new_child, $cn; |
|
|
} |
|
197 |
} else { |
} else { |
198 |
|
return $$self->{local_name}; |
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
199 |
} |
} |
200 |
|
} # tag_name |
201 |
|
|
202 |
my $nc_parent = @new_child ? $new_child[0]-> |
## TODO: Documentation |
203 |
parent_node |
sub manakai_tag_name ($) { |
204 |
: |
my $self = shift; |
205 |
|
if (defined $$self->{prefix}) { |
206 |
undef |
return $$self->{prefix} . ':' . $$self->{local_name}; |
207 |
; |
} else { |
208 |
if ($strict) { |
return $$self->{local_name}; |
|
## -- Wrong-document check |
|
|
unless ($self_od eq $child_od) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
## -- Read-onlyness check |
|
|
if ($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
if (@new_child) { |
|
|
if ($nc_parent and |
|
|
$nc_parent-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
209 |
} |
} |
210 |
|
} # manakai_tag_name |
211 |
|
|
212 |
## -- Insert at... |
## The |Element| interface - methods |
|
my $index = -1; # last |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
# tc:ForAppendChild & tc:ForReplaceChild |
|
|
if (defined $refChild) { |
|
|
if ($refChild eq $newChild) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#insert-before-itself', 'rdata' => $refChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
213 |
|
|
214 |
|
sub manakai_element_type_match ($$$) { |
215 |
} |
my ($self, $nsuri, $ln) = @_; |
216 |
|
if (defined $nsuri) { |
217 |
; |
if (defined $$self->{namespace_uri} and $nsuri eq $$self->{namespace_uri}) { |
218 |
|
return ($ln eq $$self->{local_name}); |
|
|
|
|
; |
|
|
} |
|
|
|
|
|
my $cns = $self-> |
|
|
child_nodes |
|
|
; |
|
|
my $cnsl = @$cns; |
|
|
C: { |
|
|
$index = 0; |
|
|
for my $i (0..($cnsl-1)) { |
|
|
my $cn = $cns->[$i]; |
|
|
if ($cn eq $refChild) { |
|
|
$index += $i; |
|
|
last C; |
|
|
} elsif ($cn eq $newChild) { |
|
|
$index = -1; # offset |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'refChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $refChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
; |
|
|
} # C |
|
|
} else { # |oldChild| is not defined |
|
|
|
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; # FOR !tc:ForAppendChild |
|
|
|
|
|
## -- Removes from parent |
|
|
if ($nc_parent) { |
|
|
if ($child_nt == |
|
|
11 |
|
|
) { |
|
|
$$newChild->{ |
|
|
'child' |
|
|
} = []; |
|
219 |
} else { |
} else { |
220 |
my $v = $$nc_parent->{ |
return 0; |
|
'child' |
|
|
}; |
|
|
RP: for my $i (0..$#$v) { |
|
|
if ($v->[$i] eq $new_child[0]) { |
|
|
splice @$v, $i, 1, (); |
|
|
last RP; |
|
|
} |
|
|
} # RP |
|
221 |
} |
} |
222 |
} |
} else { |
223 |
|
if (not defined $$self->{namespace_uri}) { |
224 |
## -- Rewrite the |parentNode| properties |
return ($ln eq $$self->{local_name}); |
|
for my $nc (@new_child) { |
|
|
$$nc->{ |
|
|
'parent' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$nc->{ |
|
|
'parent' |
|
|
}); |
|
|
} |
|
|
|
|
|
my $children = $$self->{ |
|
|
'child' |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
## -- Adds to children list |
|
|
if ($index == -1) { |
|
|
push @$children, @new_child; |
|
225 |
} else { |
} else { |
226 |
splice @$children, $index, 0, @new_child; |
return 0; |
227 |
} |
} |
|
$r = $newChild; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub replace_child ($$$) { |
|
|
my ($self, $newChild, $oldChild) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$self_od = $self-> |
|
|
owner_document |
|
|
; |
|
|
if ($self_od-> |
|
|
strict_error_checking |
|
|
) { |
|
|
my $anode = $self; |
|
|
while (defined $anode) { |
|
|
if ($anode eq $newChild) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_ANCESTOR_OR_SELF', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
; |
|
|
} |
|
|
$anode = $anode-> |
|
|
parent_node |
|
|
; |
|
228 |
} |
} |
229 |
} |
} # manakai_element_type_match |
|
my $child_od = $newChild-> |
|
|
owner_document |
|
|
; |
|
|
my $child_nt = $newChild-> |
|
|
node_type |
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$strict = $self_od-> |
|
|
strict_error_checking |
|
|
; |
|
|
|
|
|
## -- Node Type check |
|
|
my @new_child; |
|
|
if ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
1 => 1, |
|
|
4 => 1, |
|
|
7 => 1, |
|
|
8 => 1, |
|
|
}->{$child_nt}) { |
|
|
push @new_child, $newChild; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
|
unless ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
1 => 1, |
|
|
4 => 1, |
|
|
7 => 1, |
|
|
8 => 1, |
|
|
}->{$cn-> |
|
|
node_type |
|
|
}) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
230 |
|
|
231 |
; |
sub get_attribute ($$) { |
232 |
} |
my $attr = ${$_[0]}->{attributes}; |
233 |
push @new_child, $cn; |
my $name = ''.$_[1]; |
|
} |
|
|
} else { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
my $nc_parent = @new_child ? $new_child[0]-> |
|
|
parent_node |
|
|
: |
|
|
|
|
|
undef |
|
|
; |
|
|
if ($strict) { |
|
|
## -- Wrong-document check |
|
|
unless ($self_od eq $child_od) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
## -- Read-onlyness check |
|
|
if ($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
if (@new_child) { |
|
|
if ($nc_parent and |
|
|
$nc_parent-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1'; |
|
|
|
|
|
|
|
|
} |
|
234 |
|
|
235 |
|
## NOTE: |sort|ing is required so that every |getAttribute|, |setAttribute|, |
236 |
|
## |hasAttribute|, |removeAttribute|, or any other namespace unaware |
237 |
|
## methods operates on the same node even if there is |
238 |
|
## multiple nodes with the same qualified name. |
239 |
|
|
240 |
;} |
## NOTE: Same as |get_attribute_node|, except what is returned. |
241 |
|
|
242 |
; |
for my $ns (sort {$a cmp $b} keys %$attr) { |
243 |
|
for my $ln (sort {$a cmp $b} keys %{$attr->{$ns}}) { |
244 |
|
my $node = $attr->{$ns}->{$ln}; |
245 |
|
if ($node->manakai_name eq $name) { |
246 |
|
return $node->value; |
247 |
} |
} |
248 |
} |
} |
249 |
} |
} |
250 |
|
|
251 |
## -- Insert at... |
return undef; |
252 |
my $index = -1; # last |
} # get_attribute |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
# tc:ForAppendChild & tc:ForReplaceChild |
|
|
if (defined $oldChild) { |
|
|
if ($oldChild eq $newChild) { |
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#replace-by-itself', 'rdata' => $oldChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
253 |
|
|
254 |
|
sub get_attribute_node ($$) { |
255 |
|
my $attr = ${$_[0]}->{attributes}; |
256 |
|
my $name = ''.$_[1]; |
257 |
|
|
258 |
} |
## NOTE: Same as |get_attribute|, except what is returned. |
259 |
|
|
260 |
; |
for my $ns (sort {$a cmp $b} keys %$attr) { |
261 |
|
for my $ln (sort {$a cmp $b} keys %{$attr->{$ns}}) { |
262 |
|
my $node = $attr->{$ns}->{$ln}; |
263 |
|
if ($node->manakai_name eq $name) { |
264 |
|
return $node; |
265 |
} |
} |
|
|
|
|
my $cns = $self-> |
|
|
child_nodes |
|
|
; |
|
|
my $cnsl = @$cns; |
|
|
C: { |
|
|
$index = 0; |
|
|
for my $i (0..($cnsl-1)) { |
|
|
my $cn = $cns->[$i]; |
|
|
if ($cn eq $oldChild) { |
|
|
$index += $i; |
|
|
last C; |
|
|
} elsif ($cn eq $newChild) { |
|
|
$index = -1; # offset |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} # C |
|
|
} else { # |oldChild| is not defined |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; # FOR !tc:ForAppendChild |
|
|
|
|
|
## -- Removes from parent |
|
|
if ($nc_parent) { |
|
|
if ($child_nt == |
|
|
11 |
|
|
) { |
|
|
$$newChild->{ |
|
|
'child' |
|
|
} = []; |
|
|
} else { |
|
|
my $v = $$nc_parent->{ |
|
|
'child' |
|
|
}; |
|
|
RP: for my $i (0..$#$v) { |
|
|
if ($v->[$i] eq $new_child[0]) { |
|
|
splice @$v, $i, 1, (); |
|
|
last RP; |
|
|
} |
|
|
} # RP |
|
266 |
} |
} |
267 |
} |
} |
268 |
|
|
269 |
## -- Rewrite the |parentNode| properties |
return undef; |
270 |
for my $nc (@new_child) { |
} # get_attribute_node |
|
$$nc->{ |
|
|
'parent' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$nc->{ |
|
|
'parent' |
|
|
}); |
|
|
} |
|
|
|
|
|
my $children = $$self->{ |
|
|
'child' |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
271 |
|
|
272 |
|
sub get_attribute_ns ($$$) { |
273 |
|
my $nsuri = defined $_[1] ? ''.$_[1] : ''; |
274 |
{ |
my $ln = ''.$_[2]; |
275 |
|
if (my $attr = ${$_[0]}->{attributes}->{$nsuri}->{$ln}) { |
276 |
|
return $attr->value; |
|
## -- Replaces the node |
|
|
splice @$children, $index, 1, @new_child; |
|
|
CORE::delete $$oldChild->{ |
|
|
'parent' |
|
|
}; |
|
|
$r = $oldChild; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub attributes ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = bless \\($self), |
|
|
'Message::DOM::TreeCore::ManakaiDOMAttrMap' |
|
|
; |
|
|
$$self->{ |
|
|
'hpos' |
|
|
} ||= 0; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'attributes'; |
|
|
} |
|
|
} |
|
|
sub node_name ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$prefix = $$self->{ |
|
|
'pfx' |
|
|
}; |
|
|
my $lname = $$self->{ |
|
|
'ln' |
|
|
}; |
|
|
$r = defined $prefix ? $$prefix.':'.$$lname : $$lname; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'node_name'; |
|
|
} |
|
|
} |
|
|
sub tag_name ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$prefix = $$self->{ |
|
|
'pfx' |
|
|
}; |
|
|
my $lname = $$self->{ |
|
|
'ln' |
|
|
}; |
|
|
$r = defined $prefix ? $$prefix.':'.$$lname : $$lname; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'tag_name'; |
|
|
} |
|
|
} |
|
|
sub manakai_append_text ($$) { |
|
|
my ($self, $string) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$lc = $self-> |
|
|
last_child |
|
|
; |
|
|
if (defined $lc and |
|
|
$lc-> |
|
|
node_type |
|
|
== |
|
|
3 |
|
|
) { |
|
|
$lc-> |
|
|
manakai_append_text |
|
|
|
|
|
(ref $string eq 'SCALAR' ? $string : \$string); |
|
277 |
} else { |
} else { |
278 |
my $text = $self-> |
return undef; |
|
owner_document |
|
|
|
|
|
-> |
|
|
create_text_node |
|
|
|
|
|
(ref $string eq 'SCALAR' ? $$string : $string); |
|
|
$self-> |
|
|
append_child |
|
|
($text); |
|
279 |
} |
} |
280 |
$r = $self; |
} # get_attribute_ns |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub get_feature ($$$) { |
|
|
my ($self, $feature, $version) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$feature = lc $feature; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$version = '' unless defined $version; |
|
|
|
|
|
|
|
|
} |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$feature =~ s/^\+//; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($Message::Util::AutoLoad::Registry::Feature->{$feature}->{$version}) { |
|
|
$r = $self; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
unless (defined $r) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$r = $self->SUPER::get_feature ($feature, $version); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub base_uri ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = $$self->{ |
|
|
'buri' |
|
|
}; |
|
|
unless (defined $r) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$xb = $self-> |
|
|
get_attribute_node_ns |
|
|
|
|
|
( |
|
|
'http://www.w3.org/XML/1998/namespace' |
|
|
, 'base'); |
|
|
unless (defined $xb) { |
|
|
$xb = $self-> |
|
|
get_attribute_node_ns |
|
|
|
|
|
( |
|
|
undef |
|
|
, 'xml:base'); |
|
|
} |
|
|
if ($xb) { |
|
|
$r = $xb-> |
|
|
value |
|
|
; |
|
|
if ( |
|
|
($r !~ m!\A[^:/?#]+:!) |
|
|
) { |
|
|
my $xbbase = $xb-> |
|
|
base_uri |
|
|
; |
|
|
$r = $self-> |
|
|
owner_document |
|
|
|
|
|
-> |
|
|
implementation |
|
|
|
|
|
-> |
|
|
create_uri_reference |
|
|
|
|
|
($r) |
|
|
-> |
|
|
get_absolute_reference |
|
|
|
|
|
($xbbase) |
|
|
-> |
|
|
uri_reference |
|
|
if |
|
|
defined $xbbase; |
|
|
} |
|
|
} else { |
|
|
my $pe = $self-> |
|
|
parent_node |
|
|
; |
|
|
W: { |
|
|
while (defined $pe) { |
|
|
my $nt = $pe-> |
|
|
node_type |
|
|
; |
|
|
if ($nt == |
|
|
1 or |
|
|
|
|
|
$nt == |
|
|
9 or |
|
|
|
|
|
$nt == |
|
|
11 or |
|
|
|
|
|
$nt == |
|
|
6 |
|
|
) { |
|
|
$r = $pe-> |
|
|
base_uri |
|
|
; |
|
|
last W; |
|
|
} elsif ($nt == |
|
|
5 |
|
|
) { |
|
|
if ($pe-> |
|
|
manakai_external |
|
|
) { |
|
|
$r = $pe-> |
|
|
manakai_entity_base_uri |
|
|
; |
|
|
last W; |
|
|
} |
|
|
} |
|
|
$pe = $pe-> |
|
|
parent_node |
|
|
; |
|
|
} |
|
|
if ($pe) { |
|
|
$r = $pe-> |
|
|
base_uri |
|
|
; |
|
|
} else { |
|
|
$r = $self-> |
|
|
owner_document |
|
|
-> |
|
|
base_uri |
|
|
; |
|
|
} |
|
|
} # W |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'base_uri'; |
|
|
} |
|
|
} |
|
|
sub get_attribute ($$) { |
|
|
my ($self, $name) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$node; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$__attr = ${$self}->{ |
|
|
'attr' |
|
|
}; |
|
|
|
|
|
## Note that we no longer support DOM Level 1 nodes. |
|
|
|
|
|
## If an attribute's qualified name is equal to |
|
|
## the requested name, then the node is the answer. |
|
|
|
|
|
## Note that if there is a namespace ill-formed attribute, |
|
|
## the result is not the expected one. For example, |
|
|
## if an |xmlns| attribute in the |http://www.w3.org/2000/xmlns/| |
|
|
## namespace has non-NULL |prefix|, a request to get |xmlns| |
|
|
## attribute will not return that node. |
|
|
|
|
|
## |sort|ing is required so that every |getAttribute|, |setAttribute|, |
|
|
## |hasAttribute|, |removeAttribute|, or any other namespace unaware |
|
|
## methods operates on the same node even if there is |
|
|
## multiple nodes with the same qualified name. |
|
|
|
|
|
NS: for my $__ns (sort {$a cmp $b} keys %$__attr) { |
|
|
for my $__ln (sort {$a cmp $b} keys %{$__attr->{$__ns}}) { |
|
|
my $__node = $__attr->{$__ns}->{$__ln}; |
|
|
if ($__node-> |
|
|
node_name eq |
|
|
$name) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$node = $__node; |
|
|
|
|
|
|
|
281 |
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
; |
|
|
last NS; |
|
|
} |
|
|
} # ln |
|
|
} # NS |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
if (defined $node) { |
|
|
$r = $node-> |
|
|
value |
|
|
; |
|
|
} else { |
|
|
$r = |
|
|
undef |
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub get_attribute_ns ($$$) { |
|
|
my ($self, $namespaceURI, $localName) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) { |
|
|
require Message::DOM::DOMMain; |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#DOMNamespaceURIInputProcessor'; |
|
|
|
|
|
; |
|
|
|
|
|
$namespaceURI = undef; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$node; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$__attrs = ${$self}->{ |
|
|
'attr' |
|
|
}; |
|
|
if (defined $__attrs->{defined $namespaceURI ? $namespaceURI : ''} |
|
|
->{$localName}) { |
|
|
$node = $__attrs->{defined $namespaceURI ? $namespaceURI : ''} |
|
|
->{$localName}; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
if (defined $node) { |
|
|
$r = $node-> |
|
|
value |
|
|
; |
|
|
} else { |
|
|
$r = |
|
|
undef |
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub get_attribute_node ($$) { |
|
|
my ($self, $name) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$__attr = ${$self}->{ |
|
|
'attr' |
|
|
}; |
|
|
|
|
|
## Note that we no longer support DOM Level 1 nodes. |
|
|
|
|
|
## If an attribute's qualified name is equal to |
|
|
## the requested name, then the node is the answer. |
|
|
|
|
|
## Note that if there is a namespace ill-formed attribute, |
|
|
## the result is not the expected one. For example, |
|
|
## if an |xmlns| attribute in the |http://www.w3.org/2000/xmlns/| |
|
|
## namespace has non-NULL |prefix|, a request to get |xmlns| |
|
|
## attribute will not return that node. |
|
|
|
|
|
## |sort|ing is required so that every |getAttribute|, |setAttribute|, |
|
|
## |hasAttribute|, |removeAttribute|, or any other namespace unaware |
|
|
## methods operates on the same node even if there is |
|
|
## multiple nodes with the same qualified name. |
|
|
|
|
|
NS: for my $__ns (sort {$a cmp $b} keys %$__attr) { |
|
|
for my $__ln (sort {$a cmp $b} keys %{$__attr->{$__ns}}) { |
|
|
my $__node = $__attr->{$__ns}->{$__ln}; |
|
|
if ($__node-> |
|
|
node_name eq |
|
|
$name) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = $__node; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
; |
|
|
last NS; |
|
|
} |
|
|
} # ln |
|
|
} # NS |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
282 |
sub get_attribute_node_ns ($$$) { |
sub get_attribute_node_ns ($$$) { |
283 |
my ($self, $namespaceURI, $localName) = @_; |
return ${$_[0]}->{attributes}->{defined $_[1] ? ''.$_[1] : ''}->{''.$_[2]}; |
284 |
|
} # get_attribute_node_ns |
|
{ |
|
|
|
|
|
if |
|
|
(CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) { |
|
|
require Message::DOM::DOMMain; |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#DOMNamespaceURIInputProcessor'; |
|
|
|
|
|
; |
|
|
|
|
|
$namespaceURI = undef; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$__attrs = ${$self}->{ |
|
|
'attr' |
|
|
}; |
|
|
if (defined $__attrs->{defined $namespaceURI ? $namespaceURI : ''} |
|
|
->{$localName}) { |
|
|
$r = $__attrs->{defined $namespaceURI ? $namespaceURI : ''} |
|
|
->{$localName}; |
|
|
} |
|
|
|
|
285 |
|
|
286 |
} |
*get_elements_by_tag_name = \&Message::DOM::Document::get_elements_by_tag_name; |
287 |
|
|
288 |
; |
*get_elements_by_tag_name_ns |
289 |
|
= \&Message::DOM::Document::get_elements_by_tag_name_ns; |
290 |
|
|
|
|
|
|
} |
|
|
$r} |
|
291 |
sub has_attribute ($$) { |
sub has_attribute ($$) { |
292 |
my ($self, $name) = @_; |
my $attr = ${$_[0]}->{attributes}; |
293 |
my $r = 0; |
my $name = ''.$_[1]; |
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$node; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$__attr = ${$self}->{ |
|
|
'attr' |
|
|
}; |
|
|
|
|
|
## Note that we no longer support DOM Level 1 nodes. |
|
|
|
|
|
## If an attribute's qualified name is equal to |
|
|
## the requested name, then the node is the answer. |
|
|
|
|
|
## Note that if there is a namespace ill-formed attribute, |
|
|
## the result is not the expected one. For example, |
|
|
## if an |xmlns| attribute in the |http://www.w3.org/2000/xmlns/| |
|
|
## namespace has non-NULL |prefix|, a request to get |xmlns| |
|
|
## attribute will not return that node. |
|
|
|
|
|
## |sort|ing is required so that every |getAttribute|, |setAttribute|, |
|
|
## |hasAttribute|, |removeAttribute|, or any other namespace unaware |
|
|
## methods operates on the same node even if there is |
|
|
## multiple nodes with the same qualified name. |
|
|
|
|
|
NS: for my $__ns (sort {$a cmp $b} keys %$__attr) { |
|
|
for my $__ln (sort {$a cmp $b} keys %{$__attr->{$__ns}}) { |
|
|
my $__node = $__attr->{$__ns}->{$__ln}; |
|
|
if ($__node-> |
|
|
node_name eq |
|
|
$name) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$node = $__node; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
; |
|
|
last NS; |
|
|
} |
|
|
} # ln |
|
|
} # NS |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
$r = defined $node; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub has_attribute_ns ($$$) { |
|
|
my ($self, $namespaceURI, $localName) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) { |
|
|
require Message::DOM::DOMMain; |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#DOMNamespaceURIInputProcessor'; |
|
|
|
|
|
; |
|
|
|
|
|
$namespaceURI = undef; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
my $r = 0; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$node; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$__attrs = ${$self}->{ |
|
|
'attr' |
|
|
}; |
|
|
if (defined $__attrs->{defined $namespaceURI ? $namespaceURI : ''} |
|
|
->{$localName}) { |
|
|
$node = $__attrs->{defined $namespaceURI ? $namespaceURI : ''} |
|
|
->{$localName}; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
$r = defined $node; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub set_attribute ($$$) { |
|
|
my ($self, $name, $value) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$od = $self-> |
|
|
owner_document |
|
|
; |
|
|
if ($od-> |
|
|
strict_error_checking |
|
|
) { |
|
|
if ($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_attribute', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement'; |
|
|
|
|
|
; |
|
|
} |
|
|
my $version = $od-> |
|
|
xml_version |
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $name) { |
|
|
if (((not defined $version or $version eq '1.0') and |
|
|
not |
|
|
($name =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) |
|
|
) or |
|
|
(defined $version and $version eq '1.1' and |
|
|
not |
|
|
($name =~ /\A\p{InXMLNameStartChar11}\p{InXMLNameChar11}*\z/) |
|
|
)) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'INVALID_CHARACTER_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_BAD_NAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $name, 'http://www.w3.org/2001/04/infoset#version' => $version, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_PARAM_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
my $__anode; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$__attr = ${$self}->{ |
|
|
'attr' |
|
|
}; |
|
294 |
|
|
295 |
## Note that we no longer support DOM Level 1 nodes. |
for my $ns (keys %$attr) { |
296 |
|
for my $ln (keys %{$attr->{$ns}}) { |
297 |
## If an attribute's qualified name is equal to |
my $node = $attr->{$ns}->{$ln}; |
298 |
## the requested name, then the node is the answer. |
if ($node->manakai_name eq $name) { |
299 |
|
return 1; |
|
## Note that if there is a namespace ill-formed attribute, |
|
|
## the result is not the expected one. For example, |
|
|
## if an |xmlns| attribute in the |http://www.w3.org/2000/xmlns/| |
|
|
## namespace has non-NULL |prefix|, a request to get |xmlns| |
|
|
## attribute will not return that node. |
|
|
|
|
|
## |sort|ing is required so that every |getAttribute|, |setAttribute|, |
|
|
## |hasAttribute|, |removeAttribute|, or any other namespace unaware |
|
|
## methods operates on the same node even if there is |
|
|
## multiple nodes with the same qualified name. |
|
|
|
|
|
NS: for my $__ns (sort {$a cmp $b} keys %$__attr) { |
|
|
for my $__ln (sort {$a cmp $b} keys %{$__attr->{$__ns}}) { |
|
|
my $__node = $__attr->{$__ns}->{$__ln}; |
|
|
if ($__node-> |
|
|
node_name eq |
|
|
$name) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$__anode = $__node; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
; |
|
|
last NS; |
|
|
} |
|
|
} # ln |
|
|
} # NS |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
if (defined $__anode) { ## There is already a node with such a |name| |
|
|
if ($__anode-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_attribute', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_ATTR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'name', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $__anode; |
|
|
|
|
|
; |
|
|
} |
|
|
} else { ## There is no such attribute |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$__anode = $od-> |
|
|
create_attribute |
|
|
($name); |
|
|
CORE::delete $$self->{ |
|
|
'sattrs' |
|
|
}; |
|
|
my $__attrs = $$self->{ |
|
|
'attr' |
|
|
}; |
|
|
$__attrs->{''}->{$name} = $__anode; |
|
|
$$__anode->{ |
|
|
'owner' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$__anode->{ |
|
|
'owner' |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
## NOTE: The |cfg:xml-id| configuration parameter does not matter |
|
|
## since it can be typed in the |createAttribute| method. |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
if |
|
|
($od-> |
|
|
dom_config |
|
|
|
|
|
-> |
|
|
get_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/dtd-attribute-type' |
|
|
)) { |
|
|
my $__st_doctype = $od-> |
|
|
doctype |
|
|
; |
|
|
$__st_doctype = $__st_doctype-> |
|
|
get_feature |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/feature/XDoctype' |
|
|
=> '3.0') |
|
|
if defined $__st_doctype; |
|
|
if (defined $__st_doctype) { |
|
|
my $__st_et = $__st_doctype-> |
|
|
get_element_type_definition_node |
|
|
|
|
|
($self-> |
|
|
node_name |
|
|
); |
|
|
if (defined $__st_et) { |
|
|
my $__st_at = $__st_et-> |
|
|
get_attribute_definition_node |
|
|
|
|
|
($name); |
|
|
if (defined $__st_at) { |
|
|
$__anode-> |
|
|
manakai_attribute_type |
|
|
|
|
|
($__st_at-> |
|
|
declared_type |
|
|
); |
|
|
} |
|
300 |
} |
} |
301 |
} |
} |
302 |
} |
} |
303 |
|
|
304 |
|
return 0; |
305 |
|
} # has_attribute |
306 |
|
|
307 |
|
sub has_attribute_ns ($$$) { |
308 |
|
return ${$_[0]}->{attributes}->{defined $_[1] ? ''.$_[1] : ''}->{''.$_[2]}?1:0; |
309 |
|
} # has_attribute_ns |
310 |
|
|
311 |
} |
sub remove_attribute ($$) { |
312 |
|
my $attr = ${$_[0]}->{attributes}; |
313 |
|
my $name = ''.$_[1]; |
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$__anode-> |
|
|
value |
|
|
($value); |
|
|
$__anode-> |
|
|
specified |
|
|
( |
|
|
1 |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
sub set_attribute_ns ($$$$) { |
|
|
my ($self, $namespaceURI, $qualifiedName, $value) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) { |
|
|
require Message::DOM::DOMMain; |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#DOMNamespaceURIInputProcessor'; |
|
|
|
|
|
; |
|
|
|
|
|
$namespaceURI = undef; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
($prefix, $localName) = ref $qualifiedName eq 'ARRAY' |
|
|
? @$qualifiedName |
|
|
: split /:/, $qualifiedName, 2; |
|
|
($prefix, $localName) = ( |
|
|
undef |
|
|
, $prefix) unless defined $localName; |
|
|
|
|
|
my $od = $self-> |
|
|
owner_document |
|
|
; |
|
|
if ($od-> |
|
|
strict_error_checking |
|
|
) { |
|
|
if ($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_attribute_ns', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement'; |
|
|
|
|
|
; |
|
|
} |
|
|
my $version = $od-> |
|
|
xml_version |
|
|
; |
|
|
$qualifiedName = defined $prefix ? $prefix.':'.$localName |
|
|
: $localName; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $version and $version eq '1.1') { |
|
|
unless ( |
|
|
($qualifiedName =~ /\A\p{InXMLNameStartChar11}\p{InXMLNameChar11}*\z/) |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'INVALID_CHARACTER_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_BAD_NAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $qualifiedName, 'http://www.w3.org/2001/04/infoset#version' => '1.1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLQName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
unless ( |
|
|
($qualifiedName =~ /\A\p{InXMLNCNameStartChar11}\p{InXMLNCNameChar11}*(?::\p{InXMLNCNameStartChar11}\p{InXMLNCNameChar11}*)?\z/) |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_MALFORMED_QNAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $qualifiedName, 'http://www.w3.org/2001/04/infoset#version' => '1.1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLQName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
} else { |
|
|
unless ( |
|
|
($qualifiedName =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'INVALID_CHARACTER_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_BAD_NAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $qualifiedName, 'http://www.w3.org/2001/04/infoset#version' => $version, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLQName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
unless ( |
|
|
($qualifiedName =~ /\A\p{InXML_NCNameStartChar10}\p{InXMLNCNameChar10}*(?::\p{InXML_NCNameStartChar10}\p{InXMLNCNameChar10}*)?\z/) |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_MALFORMED_QNAME', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#name' => $qualifiedName, 'http://www.w3.org/2001/04/infoset#version' => $version, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureXMLQName', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $prefix) { |
|
|
if (not defined $namespaceURI) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#prefix' => $prefix, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_PREFIX_WITH_NULL_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} elsif ($prefix eq 'xml' and $namespaceURI ne |
|
|
'http://www.w3.org/XML/1998/namespace' |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#namespaceName' => $namespaceURI, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_XML_WITH_OTHER_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} elsif ($prefix eq 'xmlns' and $namespaceURI ne |
|
|
'http://www.w3.org/2000/xmlns/' |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#namespaceName' => $namespaceURI, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_XMLNS_WITH_OTHER_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} elsif ($namespaceURI eq |
|
|
'http://www.w3.org/XML/1998/namespace' and |
|
|
$prefix ne 'xml') { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#prefix' => $prefix, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_OTHER_WITH_XML_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} elsif ($namespaceURI eq |
|
|
'http://www.w3.org/2000/xmlns/' and |
|
|
$prefix ne 'xmlns') { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#prefix' => $prefix, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_OTHER_WITH_XMLNS_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} |
|
|
} else { ## No prefix |
|
|
if (not defined $namespaceURI) { |
|
|
# |
|
|
} elsif ($namespaceURI eq |
|
|
'http://www.w3.org/2000/xmlns/' and |
|
|
$localName ne 'xmlns') { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#prefix' => undef, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_OTHER_WITH_XMLNS_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#checkXMLNamesQName'; |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$__anode; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$__attrs = ${$self}->{ |
|
|
'attr' |
|
|
}; |
|
|
if (defined $__attrs->{defined $namespaceURI ? $namespaceURI : ''} |
|
|
->{$localName}) { |
|
|
$__anode = $__attrs->{defined $namespaceURI ? $namespaceURI : ''} |
|
|
->{$localName}; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
if (defined $__anode) { ## There is already a node with such a |name| |
|
|
if ($__anode-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_ATTR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/setAttrValueNS', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $__anode; |
|
|
|
|
|
; |
|
|
} |
|
|
$__anode-> |
|
|
prefix |
|
|
($prefix) if defined $prefix; |
|
|
## ISSUE: Should NULL be allowed here with |strictErrorChecking| off? |
|
|
} else { ## There is no such attribute |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$__anode = $od-> |
|
|
create_attribute_ns |
|
|
|
|
|
($namespaceURI, [$prefix, $localName]); |
|
|
CORE::delete $$self->{ |
|
|
'sattrs' |
|
|
}; |
|
|
my $__attrs = ${$self}->{ |
|
|
'attr' |
|
|
}; |
|
|
$__attrs->{defined $namespaceURI ? $namespaceURI : ''}->{$localName} |
|
|
= $__anode; |
|
|
$$__anode->{ |
|
|
'owner' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$__anode->{ |
|
|
'owner' |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
## NOTE: The |cfg:xml-id| configuration parameter does not matter |
|
|
## since it can be typed in the |createAttribute| method. |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
if |
|
|
($od-> |
|
|
dom_config |
|
|
|
|
|
-> |
|
|
get_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/dtd-attribute-type' |
|
|
)) { |
|
|
my $__st_doctype = $od-> |
|
|
doctype |
|
|
; |
|
|
$__st_doctype = $__st_doctype-> |
|
|
get_feature |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/feature/XDoctype' |
|
|
=> '3.0') |
|
|
if defined $__st_doctype; |
|
|
if (defined $__st_doctype) { |
|
|
my $__st_et = $__st_doctype-> |
|
|
get_element_type_definition_node |
|
|
|
|
|
($self-> |
|
|
node_name |
|
|
); |
|
|
if (defined $__st_et) { |
|
|
my $__st_at = $__st_et-> |
|
|
get_attribute_definition_node |
|
|
|
|
|
(defined $prefix ? $prefix.':'.$localName |
|
|
: $localName); |
|
|
if (defined $__st_at) { |
|
|
$__anode-> |
|
|
manakai_attribute_type |
|
314 |
|
|
315 |
($__st_at-> |
my $list; |
316 |
declared_type |
my $key; |
317 |
); |
my $attr_node; |
318 |
|
ATTR: { |
319 |
|
for my $ns (keys %$attr) { |
320 |
|
$list = $attr->{$ns}; |
321 |
|
for my $ln (keys %$list) { |
322 |
|
$attr_node = $list->{$ln}; |
323 |
|
if ($attr_node->manakai_name eq $name) { |
324 |
|
$key = $ln; |
325 |
|
last ATTR; |
326 |
} |
} |
327 |
} |
} |
328 |
} |
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$__anode-> |
|
|
value |
|
|
(defined $value ? $value : ''); |
|
|
$__anode-> |
|
|
specified |
|
|
( |
|
|
1 |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
sub set_attribute_node ($$) { |
|
|
my ($self, $newAttr) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$self_od = $self-> |
|
|
owner_document |
|
|
; |
|
|
my $strict = $self_od-> |
|
|
strict_error_checking |
|
|
; |
|
|
if ($strict and |
|
|
not $self_od eq $newAttr-> |
|
|
owner_document |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_attribute_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newAttr; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
my $nsuri = $newAttr-> |
|
|
namespace_uri |
|
|
; |
|
|
$nsuri = '' unless defined $nsuri; |
|
|
my $ln = $newAttr-> |
|
|
local_name |
|
|
; |
|
|
CORE::delete $$self->{ |
|
|
'sattrs' |
|
|
}; |
|
|
my $attrs = $$self->{ |
|
|
'attr' |
|
|
}; |
|
|
my $current = $attrs->{$nsuri}->{$ln}; |
|
|
|
|
|
if (defined $newAttr-> |
|
|
owner_element |
|
|
) { |
|
|
if (defined $current and $current eq $newAttr) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#replace-by-itself', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_attribute_node', 'rdata' => $newAttr, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement'; |
|
|
|
|
|
; |
|
|
## No return value |
|
|
} else { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'INUSE_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_attribute_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newAttr; |
|
|
|
|
|
; |
|
|
} |
|
|
} else { # not in use |
|
|
if ($strict and $self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_attribute_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
$attrs->{$nsuri}->{$ln} = $newAttr; |
|
|
$$newAttr->{ |
|
|
'owner' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$newAttr->{ |
|
|
'owner' |
|
|
}); |
|
|
$newAttr-> |
|
|
specified |
|
|
( |
|
|
1 |
|
|
); |
|
|
|
|
|
if (defined $current) { |
|
|
CORE::delete $$current->{ |
|
|
'owner' |
|
|
}; |
|
|
$r = $current; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub set_attribute_node_ns ($$) { |
|
|
my ($self, $newAttr) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$self_od = $self-> |
|
|
owner_document |
|
|
; |
|
|
my $strict = $self_od-> |
|
|
strict_error_checking |
|
|
; |
|
|
if ($strict and |
|
|
not $self_od eq $newAttr-> |
|
|
owner_document |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_attribute_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newAttr; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
my $nsuri = $newAttr-> |
|
|
namespace_uri |
|
|
; |
|
|
$nsuri = '' unless defined $nsuri; |
|
|
my $ln = $newAttr-> |
|
|
local_name |
|
|
; |
|
|
CORE::delete $$self->{ |
|
|
'sattrs' |
|
|
}; |
|
|
my $attrs = $$self->{ |
|
|
'attr' |
|
|
}; |
|
|
my $current = $attrs->{$nsuri}->{$ln}; |
|
|
|
|
|
if (defined $newAttr-> |
|
|
owner_element |
|
|
) { |
|
|
if (defined $current and $current eq $newAttr) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#replace-by-itself', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_attribute_node', 'rdata' => $newAttr, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement'; |
|
|
|
|
|
; |
|
|
## No return value |
|
|
} else { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'INUSE_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_attribute_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newAttr; |
|
|
|
|
|
; |
|
|
} |
|
|
} else { # not in use |
|
|
if ($strict and $self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_attribute_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
$attrs->{$nsuri}->{$ln} = $newAttr; |
|
|
$$newAttr->{ |
|
|
'owner' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$newAttr->{ |
|
|
'owner' |
|
|
}); |
|
|
$newAttr-> |
|
|
specified |
|
|
( |
|
|
1 |
|
|
); |
|
|
|
|
|
if (defined $current) { |
|
|
CORE::delete $$current->{ |
|
|
'owner' |
|
|
}; |
|
|
$r = $current; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub remove_attribute ($$) { |
|
|
my ($self, $name) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$list; |
|
|
my $key; |
|
|
my $attr; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$__attr = ${$self}->{ |
|
|
'attr' |
|
|
}; |
|
|
|
|
|
## Note that we no longer support DOM Level 1 nodes. |
|
|
|
|
|
## If an attribute's qualified name is equal to |
|
|
## the requested name, then the node is the answer. |
|
|
|
|
|
## Note that if there is a namespace ill-formed attribute, |
|
|
## the result is not the expected one. For example, |
|
|
## if an |xmlns| attribute in the |http://www.w3.org/2000/xmlns/| |
|
|
## namespace has non-NULL |prefix|, a request to get |xmlns| |
|
|
## attribute will not return that node. |
|
|
|
|
|
## |sort|ing is required so that every |getAttribute|, |setAttribute|, |
|
|
## |hasAttribute|, |removeAttribute|, or any other namespace unaware |
|
|
## methods operates on the same node even if there is |
|
|
## multiple nodes with the same qualified name. |
|
|
|
|
|
NS: for my $__ns (sort {$a cmp $b} keys %$__attr) { |
|
|
for my $__ln (sort {$a cmp $b} keys %{$__attr->{$__ns}}) { |
|
|
my $__node = $__attr->{$__ns}->{$__ln}; |
|
|
if ($__node-> |
|
|
node_name eq |
|
|
$name) { |
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$attr = $__node; |
|
|
$list = $__attr->{$__ns}; |
|
|
$key = $__ln; |
|
|
CORE::delete ${$__node}->{ |
|
|
'sattrs' |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
last NS; |
|
|
} |
|
|
} # ln |
|
|
} # NS |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
if (defined $attr) { |
|
|
if ($self-> |
|
|
manakai_read_only |
|
|
) { |
|
329 |
|
|
330 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'remove_attribute', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement'; |
return undef; # not found |
331 |
|
} # ATTR |
332 |
|
|
333 |
; |
my $od = ${$_[0]}->{owner_document}; |
334 |
|
if ($$od->{strict_error_checking} and ${$_[0]}->{manakai_read_only}) { |
335 |
|
report Message::DOM::DOMException |
336 |
|
-object => $_[0], |
337 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
338 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
339 |
} |
} |
340 |
|
|
341 |
## Remove the attribute node |
delete $list->{$key}; |
342 |
CORE::delete $list->{$key}; |
delete $$attr_node->{owner_element}; |
343 |
CORE::delete $$attr->{ |
$$attr_node->{specified} = 1; |
344 |
'owner' |
delete ${$_[0]}->{manakai_content_attribute_list}; |
|
}; |
|
345 |
|
|
346 |
## Default attribute |
## Default attribute |
347 |
my $doc = $self-> |
local $Error::Depth = $Error::Depth + 1; |
348 |
owner_document |
my $cfg = $od->dom_config; |
349 |
; |
if ($cfg->get_parameter |
350 |
my $doc_cfg = $doc-> |
(q<http://suika.fam.cx/www/2006/dom-config/dtd-default-attribute>)) { |
351 |
dom_config |
my $doctype = $od->doctype; |
352 |
; |
if ($doctype) { |
353 |
if ($doc_cfg-> |
my $et = $doctype->get_element_type_definition_node |
354 |
get_parameter |
($_[0]->manakai_tag_name); |
355 |
|
if ($et) { |
356 |
( |
my $at = $et->get_attribute_definition_node ($name); |
357 |
'http://suika.fam.cx/www/2006/dom-config/dtd-default-attribute' |
if ($at) { |
358 |
)) { |
local $$od->{strict_error_checking} = 0; |
359 |
my $prefix; |
my $copy_asis = $cfg->get_parameter |
360 |
|
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree>); |
361 |
|
$cfg->set_parameter |
362 |
{ |
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree> => 1); |
363 |
|
ADD: { |
364 |
|
my $def_attr_node; |
365 |
{ |
my $def_prefix = $attr_node->prefix; |
366 |
|
my $def_nsuri = ''; |
367 |
local $Error::Depth = $Error::Depth + 1; |
my $def_ln; |
368 |
|
if (defined $def_prefix) { |
369 |
{ |
$def_nsuri = |
370 |
|
$def_prefix eq 'xml' ? q<http://www.w3.org/XML/1998/namespace>: |
371 |
|
$def_prefix eq 'xmlns' ? q<http://www.w3.org/2000/xmlns/>: |
372 |
my |
$_[0]->lookup_namespace_uri ($def_prefix); |
373 |
$__doctype = $doc-> |
unless (defined $def_nsuri) { |
374 |
doctype |
## TODO: Namespace well-formedness error... |
375 |
; |
} |
376 |
$__doctype = $__doctype-> |
$def_ln = $attr_node->manakai_local_name; |
377 |
get_feature |
} else { |
378 |
( |
$def_nsuri = $name eq 'xmlns' |
379 |
'http://suika.fam.cx/www/2006/feature/XDoctype' |
? q<http://www.w3.org/2000/xmlns/> : undef; |
380 |
) |
$def_ln = $name; |
|
if $__doctype; |
|
|
if (defined $__doctype) { |
|
|
my $__et = $__doctype-> |
|
|
get_element_type_definition_node |
|
|
|
|
|
($self->node_name); |
|
|
if (defined $__et) { |
|
|
my $__orig_strict = $doc-> |
|
|
strict_error_checking |
|
|
; |
|
|
$doc-> |
|
|
strict_error_checking |
|
|
( |
|
|
0 |
|
|
); |
|
|
|
|
|
my $__at = $__et-> |
|
|
get_attribute_definition_node |
|
|
($name); |
|
|
if (defined $__at) { |
|
|
my $__copy_asis = $doc_cfg-> |
|
|
get_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree' |
|
|
); |
|
|
$doc_cfg-> |
|
|
set_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree' |
|
|
=> |
|
|
1 |
|
|
); |
|
|
ADD: { |
|
|
my $__attr; |
|
|
CORE::delete $$self->{ |
|
|
'sattrs' |
|
|
}; |
|
|
my $__attrs = ${$self}->{ |
|
|
'attr' |
|
|
}; |
|
|
if (defined $prefix) { ## prefixed attr |
|
|
my $__nsuri = $self-> |
|
|
lookup_namespace_uri |
|
|
|
|
|
($prefix); |
|
|
unless (defined $__nsuri) { |
|
|
## TODO: Namespace well-formedness error |
|
381 |
} |
} |
382 |
if (defined $__attrs->{defined $__nsuri ? $__nsuri : ''} |
if ($attr->{defined $def_nsuri ? $def_nsuri : ''}->{$def_ln}) { |
|
->{$name}) { |
|
383 |
## TODO: Namespace well-formedness warning? |
## TODO: Namespace well-formedness warning? |
384 |
last ADD; |
last ADD; |
385 |
} |
} |
386 |
$__attr = $doc-> |
$def_attr_node = $od->create_attribute_ns |
387 |
create_attribute_ns |
($def_nsuri, [$def_prefix, $def_ln]); |
388 |
|
|
389 |
($__nsuri, [$prefix, $name]); |
for my $child (@{$at->child_nodes}) { |
390 |
} else { ## local attr |
$def_attr_node->append_child ($child->clone_node (1)); |
|
if ($name eq 'xmlns') { |
|
|
if (defined $__attrs->{ |
|
|
'http://www.w3.org/2000/xmlns/' |
|
|
}->{xmlns}) { |
|
|
## TODO: Namespace well-formedness warning? |
|
|
last ADD; |
|
|
} |
|
|
$__attr = $doc-> |
|
|
create_attribute_ns |
|
|
|
|
|
( |
|
|
'http://www.w3.org/2000/xmlns/' |
|
|
, 'xmlns'); |
|
|
} else { |
|
|
if (defined $__attrs->{''}->{$name}) { |
|
|
## TODO: Namespace well-formedness warning? |
|
|
last ADD; |
|
|
} |
|
|
$__attr = $doc-> |
|
|
create_attribute |
|
|
($name); |
|
391 |
} |
} |
392 |
} |
$def_attr_node->manakai_attribute_type ($at->declared_type); |
393 |
for my $__at_child (@{$__at-> |
$attr->{defined $def_nsuri ? $def_nsuri : ''}->{$def_ln} |
394 |
child_nodes |
= $def_attr_node; |
395 |
}) { |
$$def_attr_node->{owner_element} = $_[0]; |
396 |
$__attr-> |
Scalar::Util::weaken ($$def_attr_node->{owner_element}); |
397 |
append_child |
delete $$def_attr_node->{specified}; |
398 |
|
} # ADD |
399 |
($__at_child-> |
$cfg->set_parameter |
400 |
clone_node |
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree> => $copy_asis); |
401 |
( |
} |
|
1 |
|
|
)); |
|
|
} |
|
|
$__attr-> |
|
|
manakai_attribute_type |
|
|
|
|
|
($__at-> |
|
|
declared_type |
|
|
); |
|
|
$self-> |
|
|
set_attribute_node_ns |
|
|
($__attr); |
|
|
## This method change the |specified| flag |
|
|
$__attr-> |
|
|
specified |
|
|
( |
|
|
0 |
|
|
); |
|
|
} # ADD |
|
|
$doc_cfg-> |
|
|
set_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree' |
|
|
=> $__copy_asis); |
|
402 |
} |
} |
403 |
$doc-> |
} |
|
strict_error_checking |
|
|
($__orig_strict); |
|
|
} # et |
|
|
} # doctype |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
404 |
} |
} |
|
} # exists |
|
405 |
|
|
406 |
|
return undef; |
407 |
|
} # remove_attribute |
408 |
|
|
409 |
} |
sub remove_attribute_node ($$) { |
410 |
} |
my $od = ${$_[0]}->{owner_document}; |
411 |
sub remove_attribute_ns ($$$) { |
if ($$od->{strict_error_checking} and ${$_[0]}->{manakai_read_only}) { |
412 |
my ($self, $namespaceURI, $localName) = @_; |
report Message::DOM::DOMException |
413 |
|
-object => $_[0], |
414 |
{ |
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
415 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
416 |
if |
} |
417 |
(CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) { |
|
418 |
require Message::DOM::DOMMain; |
my $attr_node = $_[1]; |
419 |
|
my $ln = $attr_node->manakai_local_name; |
420 |
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#DOMNamespaceURIInputProcessor'; |
my $attr = ${$_[0]}->{attributes}; |
421 |
|
FIND: { |
422 |
; |
my $nsuri = $attr_node->namespace_uri; |
423 |
|
my $list = $attr->{defined $nsuri ? $nsuri : ''}; |
424 |
$namespaceURI = undef; |
my $list_node = $list->{$ln}; |
425 |
} |
if (defined $list_node and $list_node eq $attr_node) { |
426 |
|
delete $list->{$ln}; |
427 |
|
last FIND; |
428 |
} |
} |
429 |
|
|
430 |
{ |
report Message::DOM::DOMException |
431 |
|
-object => $_[0], |
432 |
my |
-type => 'NOT_FOUND_ERR', |
433 |
$list; |
-subtype => 'NOT_CHILD_ERR'; |
434 |
my $attr; |
} # FIND |
435 |
|
|
436 |
|
delete ${$_[0]}->{manakai_content_attribute_list}; |
437 |
{ |
delete $$attr_node->{owner_element}; |
438 |
|
$$attr_node->{specified} = 1; |
439 |
my |
|
|
$__attrs = ${$self}->{ |
|
|
'attr' |
|
|
}; |
|
|
$list = $__attrs->{defined $namespaceURI ? $namespaceURI : ''}; |
|
|
if (defined $list and defined $list->{$localName}) { |
|
|
$attr = $__attrs->{defined $namespaceURI ? $namespaceURI : ''} |
|
|
->{$localName}; |
|
|
CORE::delete ${$self}->{ |
|
|
'sattrs' |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
if (defined $attr) { |
|
|
if ($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'remove_attribute_ns', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
## Removes the attribute node |
|
|
CORE::delete $list->{$localName}; |
|
|
CORE::delete $$attr->{ |
|
|
'owner' |
|
|
}; |
|
|
|
|
440 |
## Default attribute |
## Default attribute |
441 |
my $doc = $self-> |
## Same as |remove_attribute|'s, except where marked as "***". |
442 |
owner_document |
local $Error::Depth = $Error::Depth + 1; |
443 |
; |
my $cfg = $od->dom_config; |
444 |
my $doc_cfg = $doc-> |
if ($cfg->get_parameter |
445 |
dom_config |
(q<http://suika.fam.cx/www/2006/dom-config/dtd-default-attribute>)) { |
446 |
; |
my $doctype = $od->doctype; |
447 |
if ($doc_cfg-> |
if ($doctype) { |
448 |
get_parameter |
my $et = $doctype->get_element_type_definition_node |
449 |
|
($_[0]->manakai_tag_name); |
450 |
( |
if ($et) { |
451 |
'http://suika.fam.cx/www/2006/dom-config/dtd-default-attribute' |
my $at = $et->get_attribute_definition_node ($_[1]->manakai_name); # *** |
452 |
)) { |
if ($at) { |
453 |
my $pfx = $attr-> |
local $$od->{strict_error_checking} = 0; |
454 |
prefix |
my $copy_asis = $cfg->get_parameter |
455 |
; |
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree>); |
456 |
my $name = defined $pfx ? $pfx.':'.$localName : $localName; |
$cfg->set_parameter |
457 |
|
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree> => 1); |
458 |
|
ADD: { |
459 |
{ |
my $def_attr_node; |
460 |
|
my $def_prefix = $attr_node->prefix; |
461 |
|
my $def_nsuri = ''; |
462 |
{ |
my $def_ln; |
463 |
|
if (defined $def_prefix) { |
464 |
local $Error::Depth = $Error::Depth + 1; |
$def_nsuri = |
465 |
|
$def_prefix eq 'xml' ? q<http://www.w3.org/XML/1998/namespace>: |
466 |
{ |
$def_prefix eq 'xmlns' ? q<http://www.w3.org/2000/xmlns/>: |
467 |
|
$_[0]->lookup_namespace_uri ($def_prefix); |
468 |
|
unless (defined $def_nsuri) { |
469 |
my |
## TODO: Namespace well-formedness error... |
470 |
$__doctype = $doc-> |
} |
471 |
doctype |
$def_ln = $attr_node->manakai_local_name; |
472 |
; |
} else { |
473 |
$__doctype = $__doctype-> |
$def_nsuri = $attr_node->manakai_name eq 'xmlns' |
474 |
get_feature |
? q<http://www.w3.org/2000/xmlns/> : undef; |
475 |
( |
$def_ln = $attr_node->manakai_local_name; ## *** |
|
'http://suika.fam.cx/www/2006/feature/XDoctype' |
|
|
) |
|
|
if $__doctype; |
|
|
if (defined $__doctype) { |
|
|
my $__et = $__doctype-> |
|
|
get_element_type_definition_node |
|
|
|
|
|
($self->node_name); |
|
|
if (defined $__et) { |
|
|
my $__orig_strict = $doc-> |
|
|
strict_error_checking |
|
|
; |
|
|
$doc-> |
|
|
strict_error_checking |
|
|
( |
|
|
0 |
|
|
); |
|
|
|
|
|
my $__at = $__et-> |
|
|
get_attribute_definition_node |
|
|
($name); |
|
|
if (defined $__at) { |
|
|
my $__copy_asis = $doc_cfg-> |
|
|
get_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree' |
|
|
); |
|
|
$doc_cfg-> |
|
|
set_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree' |
|
|
=> |
|
|
1 |
|
|
); |
|
|
ADD: { |
|
|
my $__attr; |
|
|
CORE::delete $$self->{ |
|
|
'sattrs' |
|
|
}; |
|
|
my $__attrs = ${$self}->{ |
|
|
'attr' |
|
|
}; |
|
|
if (defined $pfx) { ## prefixed attr |
|
|
my $__nsuri = $self-> |
|
|
lookup_namespace_uri |
|
|
|
|
|
($pfx); |
|
|
unless (defined $__nsuri) { |
|
|
## TODO: Namespace well-formedness error |
|
476 |
} |
} |
477 |
if (defined $__attrs->{defined $__nsuri ? $__nsuri : ''} |
if ($attr->{defined $def_nsuri ? $def_nsuri : ''}->{$def_ln}) { |
|
->{$localName}) { |
|
478 |
## TODO: Namespace well-formedness warning? |
## TODO: Namespace well-formedness warning? |
479 |
last ADD; |
last ADD; |
480 |
} |
} |
481 |
$__attr = $doc-> |
$def_attr_node = $od->create_attribute_ns |
482 |
create_attribute_ns |
($def_nsuri, [$def_prefix, $def_ln]); |
483 |
|
|
484 |
($__nsuri, [$pfx, $localName]); |
for my $child (@{$at->child_nodes}) { |
485 |
} else { ## local attr |
$def_attr_node->append_child ($child->clone_node (1)); |
|
if ($name eq 'xmlns') { |
|
|
if (defined $__attrs->{ |
|
|
'http://www.w3.org/2000/xmlns/' |
|
|
}->{xmlns}) { |
|
|
## TODO: Namespace well-formedness warning? |
|
|
last ADD; |
|
|
} |
|
|
$__attr = $doc-> |
|
|
create_attribute_ns |
|
|
|
|
|
( |
|
|
'http://www.w3.org/2000/xmlns/' |
|
|
, 'xmlns'); |
|
|
} else { |
|
|
if (defined $__attrs->{''}->{$name}) { |
|
|
## TODO: Namespace well-formedness warning? |
|
|
last ADD; |
|
|
} |
|
|
$__attr = $doc-> |
|
|
create_attribute |
|
|
($name); |
|
486 |
} |
} |
487 |
} |
$def_attr_node->manakai_attribute_type ($at->declared_type); |
488 |
for my $__at_child (@{$__at-> |
$attr->{defined $def_nsuri ? $def_nsuri : ''}->{$def_ln} |
489 |
child_nodes |
= $def_attr_node; |
490 |
}) { |
$$def_attr_node->{owner_element} = $_[0]; |
491 |
$__attr-> |
Scalar::Util::weaken ($$def_attr_node->{owner_element}); |
492 |
append_child |
delete $$def_attr_node->{specified}; |
493 |
|
} # ADD |
494 |
($__at_child-> |
$cfg->set_parameter |
495 |
clone_node |
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree> => $copy_asis); |
496 |
( |
} |
|
1 |
|
|
)); |
|
|
} |
|
|
$__attr-> |
|
|
manakai_attribute_type |
|
|
|
|
|
($__at-> |
|
|
declared_type |
|
|
); |
|
|
$self-> |
|
|
set_attribute_node_ns |
|
|
($__attr); |
|
|
## This method change the |specified| flag |
|
|
$__attr-> |
|
|
specified |
|
|
( |
|
|
0 |
|
|
); |
|
|
} # ADD |
|
|
$doc_cfg-> |
|
|
set_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree' |
|
|
=> $__copy_asis); |
|
497 |
} |
} |
498 |
$doc-> |
} |
|
strict_error_checking |
|
|
($__orig_strict); |
|
|
} # et |
|
|
} # doctype |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
} # exists |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
sub remove_attribute_node ($$) { |
|
|
my ($self, $oldAttr) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$od = $self-> |
|
|
owner_document |
|
|
; |
|
|
if ($od-> |
|
|
strict_error_checking and |
|
|
|
|
|
$self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'remove_attribute_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
my $ln = $oldAttr-> |
|
|
local_name |
|
|
; |
|
|
FIND: { |
|
|
CORE::delete $$self->{ |
|
|
'sattrs' |
|
|
}; |
|
|
my $attrs = $$self->{ |
|
|
'attr' |
|
|
}; |
|
|
my $nsuri = $oldAttr-> |
|
|
namespace_uri |
|
|
; |
|
|
my $list = $attrs->{defined $nsuri ? $nsuri : ''}; |
|
|
my $list_node = $list->{$ln}; |
|
|
if (defined $list_node and $list_node eq $oldAttr) { |
|
|
CORE::delete $list->{$ln}; |
|
|
last FIND; |
|
499 |
} |
} |
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'remove_attribute_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_ATTR_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldAttr; |
|
|
|
|
|
; |
|
|
} # FIND |
|
|
|
|
|
CORE::delete $$oldAttr->{ |
|
|
'owner' |
|
|
}; |
|
|
$r = $oldAttr; |
|
|
|
|
|
## Default attribute |
|
|
my $doc_cfg = $od-> |
|
|
dom_config |
|
|
; |
|
|
if ($doc_cfg-> |
|
|
get_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/dtd-default-attribute' |
|
|
)) { |
|
|
my $name = $oldAttr-> |
|
|
node_name |
|
|
; |
|
|
my $pfx = $oldAttr-> |
|
|
prefix |
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
500 |
|
|
501 |
|
return $_[1]; |
502 |
|
} # remove_attribute_node |
503 |
|
|
504 |
{ |
sub remove_attribute_ns ($$$) { |
505 |
|
my $attr = ${$_[0]}->{attributes}; |
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
506 |
|
|
507 |
|
my $list = $attr->{defined $_[1] ? $_[1] : ''}; |
508 |
|
my $key = ''.$_[2]; |
509 |
|
my $attr_node = $list->{$key}; |
510 |
|
return undef unless defined $attr_node; |
511 |
|
|
512 |
|
## NOTE: Anything below is same as |remove_attribute|'s except "***" |
513 |
|
|
514 |
|
my $od = ${$_[0]}->{owner_document}; |
515 |
|
if ($$od->{strict_error_checking} and ${$_[0]}->{manakai_read_only}) { |
516 |
|
report Message::DOM::DOMException |
517 |
|
-object => $_[0], |
518 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
519 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
520 |
|
} |
521 |
|
|
522 |
|
delete $list->{$key}; |
523 |
|
delete $$attr_node->{owner_element}; |
524 |
|
$$attr_node->{specified} = 1; |
525 |
|
delete ${$_[0]}->{manakai_content_attribute_list}; |
526 |
|
|
527 |
my |
## Default attribute |
528 |
$__doctype = $od-> |
local $Error::Depth = $Error::Depth + 1; |
529 |
doctype |
my $cfg = $od->dom_config; |
530 |
; |
if ($cfg->get_parameter |
531 |
$__doctype = $__doctype-> |
(q<http://suika.fam.cx/www/2006/dom-config/dtd-default-attribute>)) { |
532 |
get_feature |
my $doctype = $od->doctype; |
533 |
( |
if ($doctype) { |
534 |
'http://suika.fam.cx/www/2006/feature/XDoctype' |
my $et = $doctype->get_element_type_definition_node |
535 |
) |
($_[0]->manakai_tag_name); |
536 |
if $__doctype; |
if ($et) { |
537 |
if (defined $__doctype) { |
my $at = $et->get_attribute_definition_node |
538 |
my $__et = $__doctype-> |
($attr_node->manakai_name); # *** |
539 |
get_element_type_definition_node |
if ($at) { |
540 |
|
local $$od->{strict_error_checking} = 0; |
541 |
($self->node_name); |
my $copy_asis = $cfg->get_parameter |
542 |
if (defined $__et) { |
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree>); |
543 |
my $__orig_strict = $od-> |
$cfg->set_parameter |
544 |
strict_error_checking |
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree> => 1); |
545 |
; |
ADD: { |
546 |
$od-> |
my $def_attr_node; |
547 |
strict_error_checking |
my $def_prefix = $attr_node->prefix; |
548 |
( |
my $def_nsuri = ''; |
549 |
0 |
my $def_ln; |
550 |
); |
if (defined $def_prefix) { |
551 |
|
$def_nsuri = |
552 |
my $__at = $__et-> |
$def_prefix eq 'xml' ? q<http://www.w3.org/XML/1998/namespace>: |
553 |
get_attribute_definition_node |
$def_prefix eq 'xmlns' ? q<http://www.w3.org/2000/xmlns/>: |
554 |
($name); |
$_[0]->lookup_namespace_uri ($def_prefix); |
555 |
if (defined $__at) { |
unless (defined $def_nsuri) { |
556 |
my $__copy_asis = $doc_cfg-> |
## TODO: Namespace well-formedness error... |
557 |
get_parameter |
} |
558 |
|
} else { |
559 |
( |
$def_nsuri = $attr_node->manakai_name eq 'xmlns' |
560 |
'http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree' |
? q<http://www.w3.org/2000/xmlns/> : undef; |
|
); |
|
|
$doc_cfg-> |
|
|
set_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree' |
|
|
=> |
|
|
1 |
|
|
); |
|
|
ADD: { |
|
|
my $__attr; |
|
|
CORE::delete $$self->{ |
|
|
'sattrs' |
|
|
}; |
|
|
my $__attrs = ${$self}->{ |
|
|
'attr' |
|
|
}; |
|
|
if (defined $pfx) { ## prefixed attr |
|
|
my $__nsuri = $self-> |
|
|
lookup_namespace_uri |
|
|
|
|
|
($pfx); |
|
|
unless (defined $__nsuri) { |
|
|
## TODO: Namespace well-formedness error |
|
561 |
} |
} |
562 |
if (defined $__attrs->{defined $__nsuri ? $__nsuri : ''} |
$def_ln = $attr_node->manakai_local_name; # *** |
563 |
->{$ln}) { |
if ($attr->{defined $def_nsuri ? $def_nsuri : ''}->{$def_ln}) { |
564 |
## TODO: Namespace well-formedness warning? |
## TODO: Namespace well-formedness warning? |
565 |
last ADD; |
last ADD; |
566 |
} |
} |
567 |
$__attr = $od-> |
$def_attr_node = $od->create_attribute_ns |
568 |
create_attribute_ns |
($def_nsuri, [$def_prefix, $def_ln]); |
569 |
|
|
570 |
($__nsuri, [$pfx, $ln]); |
for my $child (@{$at->child_nodes}) { |
571 |
} else { ## local attr |
$def_attr_node->append_child ($child->clone_node (1)); |
|
if ($name eq 'xmlns') { |
|
|
if (defined $__attrs->{ |
|
|
'http://www.w3.org/2000/xmlns/' |
|
|
}->{xmlns}) { |
|
|
## TODO: Namespace well-formedness warning? |
|
|
last ADD; |
|
|
} |
|
|
$__attr = $od-> |
|
|
create_attribute_ns |
|
|
|
|
|
( |
|
|
'http://www.w3.org/2000/xmlns/' |
|
|
, 'xmlns'); |
|
|
} else { |
|
|
if (defined $__attrs->{''}->{$name}) { |
|
|
## TODO: Namespace well-formedness warning? |
|
|
last ADD; |
|
|
} |
|
|
$__attr = $od-> |
|
|
create_attribute |
|
|
($name); |
|
572 |
} |
} |
573 |
} |
$def_attr_node->manakai_attribute_type ($at->declared_type); |
574 |
for my $__at_child (@{$__at-> |
$attr->{defined $def_nsuri ? $def_nsuri : ''}->{$def_ln} |
575 |
child_nodes |
= $def_attr_node; |
576 |
}) { |
$$def_attr_node->{owner_element} = $_[0]; |
577 |
$__attr-> |
Scalar::Util::weaken ($$def_attr_node->{owner_element}); |
578 |
append_child |
delete $$def_attr_node->{specified}; |
579 |
|
} # ADD |
580 |
($__at_child-> |
$cfg->set_parameter |
581 |
clone_node |
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree> => $copy_asis); |
582 |
( |
} |
|
1 |
|
|
)); |
|
|
} |
|
|
$__attr-> |
|
|
manakai_attribute_type |
|
|
|
|
|
($__at-> |
|
|
declared_type |
|
|
); |
|
|
$self-> |
|
|
set_attribute_node_ns |
|
|
($__attr); |
|
|
## This method change the |specified| flag |
|
|
$__attr-> |
|
|
specified |
|
|
( |
|
|
0 |
|
|
); |
|
|
} # ADD |
|
|
$doc_cfg-> |
|
|
set_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree' |
|
|
=> $__copy_asis); |
|
|
} |
|
|
$od-> |
|
|
strict_error_checking |
|
|
($__orig_strict); |
|
|
} # et |
|
|
} # doctype |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub schema_type_info ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$v = 0 || 0; |
|
|
$r = bless \$v, |
|
|
'Message::DOM::Element::ManakaiDOMDTDTypeInfo' |
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'schema_type_info'; |
|
|
} |
|
|
} |
|
|
sub get_elements_by_tag_name ($$) { |
|
|
my ($self, $name) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$name = "$name"; |
|
|
my $chk; |
|
|
if ($name eq '*') { |
|
|
$chk = sub { |
|
|
1 |
|
|
}; |
|
|
} else { |
|
|
$chk = sub { |
|
|
my $node = shift; |
|
|
my $nodeName = $node-> |
|
|
node_name |
|
|
; |
|
|
($nodeName eq $name); |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = bless \[$self, $chk], |
|
|
'Message::DOM::TreeCore::ManakaiDOMGetElementsNodeList' |
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub get_elements_by_tag_name_ns ($$$) { |
|
|
my ($self, $namespaceURI, $localName) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) { |
|
|
require Message::DOM::DOMMain; |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#DOMNamespaceURIInputProcessor'; |
|
|
|
|
|
; |
|
|
|
|
|
$namespaceURI = undef; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$namespaceURI = "$namespaceURI" if defined $namespaceURI; |
|
|
$localName = "$localName"; |
|
|
my $chk; |
|
|
if (not defined $namespaceURI) { |
|
|
if ($localName eq '*') { |
|
|
$chk = sub { |
|
|
my $node = shift; |
|
|
(not defined $node-> |
|
|
namespace_uri |
|
|
); |
|
|
}; |
|
|
} else { |
|
|
$chk = sub { |
|
|
my $node = shift; |
|
|
(not defined $node-> |
|
|
namespace_uri and |
|
|
|
|
|
$node-> |
|
|
local_name eq |
|
|
$localName); |
|
|
}; |
|
|
} |
|
|
} elsif ($namespaceURI eq '*') { |
|
|
if ($localName eq '*') { |
|
|
$chk = sub { |
|
|
1 |
|
|
}; |
|
|
} else { |
|
|
$chk = sub { |
|
|
my $node = shift; |
|
|
($node-> |
|
|
local_name eq |
|
|
$localName); |
|
|
}; |
|
|
} |
|
|
} else { |
|
|
if ($localName eq '*') { |
|
|
$chk = sub { |
|
|
my $node = shift; |
|
|
my $nsuri = $node-> |
|
|
namespace_uri |
|
|
; |
|
|
(defined $nsuri and $nsuri eq $namespaceURI); |
|
|
}; |
|
|
} else { |
|
|
$chk = sub { |
|
|
my $node = shift; |
|
|
my $nsuri = $node-> |
|
|
namespace_uri |
|
|
; |
|
|
(defined $nsuri and $nsuri eq $namespaceURI and |
|
|
$node-> |
|
|
local_name eq |
|
|
$localName); |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = bless \[$self, $chk], |
|
|
'Message::DOM::TreeCore::ManakaiDOMGetElementsNodeList' |
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub manakai_base_uri ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = $$self->{ |
|
|
'buri' |
|
|
}; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self, $given) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
$$self->{ |
|
|
'buri' |
|
|
} = $given; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
sub set_id_attribute ($$;$) { |
|
|
my ($self, $name, $isId) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
my $attr = $self-> |
|
|
get_attribute_node |
|
|
($name); |
|
|
if (not defined $attr) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_id_attribute', 'http://www.w3.org/2001/04/infoset#namespaceName' => undef, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NO_NAMED_NODE_NS_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'name', 'http://www.w3.org/2001/04/infoset#localName' => $name; |
|
|
|
|
|
; |
|
|
} elsif ($attr-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_id_attribute', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_ATTR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'name', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $attr; |
|
|
|
|
|
; |
|
|
} else { |
|
|
$attr-> |
|
|
is_id |
|
|
($isId); |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
sub set_id_attribute_ns ($$$;$) { |
|
|
my ($self, $namespaceURI, $localName, $isId) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) { |
|
|
require Message::DOM::DOMMain; |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#DOMNamespaceURIInputProcessor'; |
|
|
|
|
|
; |
|
|
|
|
|
$namespaceURI = undef; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
my $attr = $self-> |
|
|
get_attribute_node_ns |
|
|
|
|
|
($namespaceURI, $localName); |
|
|
if (not defined $attr) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_id_attribute_ns', 'http://www.w3.org/2001/04/infoset#namespaceName' => $namespaceURI, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NO_NAMED_NODE_NS_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'name', 'http://www.w3.org/2001/04/infoset#localName' => $localName; |
|
|
|
|
|
; |
|
|
} elsif ($attr-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_id_attribute_ns', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_ATTR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'name', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $attr; |
|
|
|
|
|
; |
|
|
} else { |
|
|
$attr-> |
|
|
is_id |
|
|
($isId); |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
sub set_id_attribute_node ($$;$) { |
|
|
my ($self, $idAttr, $isId) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
my $owner = $idAttr-> |
|
|
owner_element |
|
|
; |
|
|
if (not defined $owner or not $owner eq $self) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_id_attribute_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_ATTR_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'idAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $idAttr; |
|
|
|
|
|
; |
|
|
} elsif ($idAttr-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'set_id_attribute_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_ATTR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMElement', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'name', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $idAttr; |
|
|
|
|
|
; |
|
|
} else { |
|
|
$idAttr-> |
|
|
is_id |
|
|
($isId); |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
$Message::DOM::DOMFeature::ClassInfo->{q<Message::DOM::Element::ManakaiDOMElement>}->{has_feature} = {'core', |
|
|
{'', |
|
|
'1', |
|
|
'1.0', |
|
|
'1', |
|
|
'2.0', |
|
|
'1', |
|
|
'3.0', |
|
|
'1'}, |
|
|
'xml', |
|
|
{'', |
|
|
'1', |
|
|
'1.0', |
|
|
'1', |
|
|
'2.0', |
|
|
'1', |
|
|
'3.0', |
|
|
'1'}, |
|
|
'xmlversion', |
|
|
{'', |
|
|
'1', |
|
|
'1.0', |
|
|
'1', |
|
|
'1.1', |
|
|
'1'}}; |
|
|
$Message::DOM::ClassPoint{q<Message::DOM::Element::ManakaiDOMElement>} = 14.1; |
|
|
package Message::DOM::IF::Attr; |
|
|
our $VERSION = 20061231.0930; |
|
|
package Message::DOM::Element::ManakaiDOMAttr; |
|
|
our $VERSION = 20061231.0930; |
|
|
push our @ISA, 'Message::DOM::TreeCore::ManakaiDOMNode', |
|
|
'Message::DOM::IF::Attr', |
|
|
'Message::DOM::IF::Node'; |
|
|
use Char::Class::XML 'InXMLNameChar10', |
|
|
'InXMLNameChar11', |
|
|
'InXMLNameStartChar11', |
|
|
'InXML_NameStartChar10'; |
|
|
sub node_type ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r; |
|
|
$r = 2; |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'node_type'; |
|
|
} |
|
|
} |
|
|
sub prefix ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$v = $$self->{ |
|
|
'pfx' |
|
|
}; |
|
|
$r = defined $v ? $$v : |
|
|
undef |
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self, $given) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$od = $self-> |
|
|
owner_document |
|
|
; |
|
|
if ($od-> |
|
|
strict_error_checking |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
my $nsuri = $$self->{ |
|
|
'ns' |
|
|
}; |
|
|
if (not defined $nsuri) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#namespaceName' => undef, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'set', 'http://www.w3.org/2001/04/infoset#prefix' => $given, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_PREFIX_WITH_NULL_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'prefix'; |
|
|
|
|
|
; |
|
|
} elsif ($$nsuri ne |
|
|
'http://www.w3.org/XML/1998/namespace' and |
|
|
|
|
|
defined $given and $given eq 'xml') { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#namespaceName' => $self->namespace_uri, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'set', 'http://www.w3.org/2001/04/infoset#prefix' => $given, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_XML_WITH_OTHER_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'prefix'; |
|
|
|
|
|
; |
|
|
} elsif ($$nsuri ne |
|
|
'http://www.w3.org/2000/xmlns/' and |
|
|
|
|
|
defined $given and $given eq 'xmlns') { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#namespaceName' => $self->namespace_uri, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'set', 'http://www.w3.org/2001/04/infoset#prefix' => $given, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_XMLNS_WITH_OTHER_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'prefix'; |
|
|
|
|
|
; |
|
|
} elsif ($self-> |
|
|
node_name eq |
|
|
'xmlns') { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#namespaceName' => $self->namespace_uri, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'set', 'http://www.w3.org/2001/04/infoset#prefix' => $given, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_QNAME_IS_XMLNS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'prefix'; |
|
|
|
|
|
; |
|
|
} |
|
|
my $version = $od-> |
|
|
xml_version |
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(defined $given and $given eq '') { |
|
|
require Message::DOM::DOMMain; |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-prefix', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureNamespacePrefix'; |
|
|
|
|
|
; |
|
|
undef $given; |
|
|
} |
|
|
if (defined $given) { |
|
|
if (($version eq '1.0' and |
|
|
not |
|
|
($given =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) |
|
|
) or |
|
|
($version eq '1.1' and |
|
|
not |
|
|
($given =~ /\A\p{InXMLNameStartChar11}\p{InXMLNameChar11}*\z/) |
|
|
)) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'INVALID_CHARACTER_ERR', 'http://www.w3.org/2001/04/infoset#name' => $given, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_BAD_NAME', 'http://www.w3.org/2001/04/infoset#version' => $version, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureNamespacePrefix', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_PARAM_NAME'; |
|
|
|
|
|
; |
|
|
} elsif (index ($given, ':') > -1) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://www.w3.org/2001/04/infoset#name' => $given, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_BAD_NCNAME', 'http://www.w3.org/2001/04/infoset#version' => $version, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#ensureNamespacePrefix', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => '$INPUT_PARAM_NAME'; |
|
|
|
|
|
; |
|
|
} |
|
|
} # has prefix |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} # strict |
|
|
if (defined $given) { |
|
|
$$self->{ |
|
|
'pfx' |
|
|
} = \$given; |
|
|
} else { |
|
|
CORE::delete $$self->{ |
|
|
'pfx' |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
sub append_child ($$) { |
|
|
my ($self, $newChild) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$self_od = $self-> |
|
|
owner_document |
|
|
; |
|
|
my $child_od = $newChild-> |
|
|
owner_document |
|
|
; |
|
|
my $child_nt = $newChild-> |
|
|
node_type |
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$strict = $self_od-> |
|
|
strict_error_checking |
|
|
; |
|
|
|
|
|
## -- Node Type check |
|
|
my @new_child; |
|
|
if ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
}->{$child_nt}) { |
|
|
push @new_child, $newChild; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
|
unless ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
}->{$cn-> |
|
|
node_type |
|
|
}) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
583 |
} |
} |
|
push @new_child, $cn; |
|
584 |
} |
} |
|
} else { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
585 |
} |
} |
586 |
|
|
587 |
my $nc_parent = @new_child ? $new_child[0]-> |
return undef; |
588 |
parent_node |
} # remove_attribute_ns |
|
: |
|
|
|
|
|
undef |
|
|
; |
|
|
if ($strict) { |
|
|
## -- Wrong-document check |
|
|
unless ($self_od eq $child_od) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
## -- Read-onlyness check |
|
|
if ($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
589 |
|
|
590 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1'; |
sub set_attribute ($$$) { |
591 |
|
my $od = ${$_[0]}->{owner_document}; |
592 |
|
if ($$od->{strict_error_checking}) { |
593 |
} |
if (${$_[0]}->{manakai_read_only}) { |
594 |
|
report Message::DOM::DOMException |
595 |
|
-object => $_[0], |
596 |
;} |
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
597 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
|
; |
|
598 |
} |
} |
599 |
if (@new_child) { |
} |
|
if ($nc_parent and |
|
|
$nc_parent-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
600 |
|
|
601 |
; |
my $name = ''.$_[1]; |
602 |
|
my $attr = ${$_[0]}->{attributes}; |
603 |
|
my $attr_node; |
604 |
|
NS: for my $ns (keys %$attr) { |
605 |
|
for my $ln (keys %{$attr->{$ns}}) { |
606 |
|
my $node = $attr->{$ns}->{$ln}; |
607 |
|
if ($node->manakai_name eq $name) { |
608 |
|
$attr_node = $node; |
609 |
|
last NS; |
610 |
} |
} |
611 |
} |
} |
612 |
} |
} |
|
|
|
|
## -- Insert at... |
|
|
my $index = -1; # last |
|
613 |
|
|
614 |
|
local $Error::Depth = $Error::Depth + 1; |
615 |
; # FOR !tc:ForAppendChild |
if (defined $attr_node) { |
616 |
|
if ($$od->{strict_error_checking}) { |
617 |
## -- Removes from parent |
$od->create_attribute ($name); # or exception |
618 |
if ($nc_parent) { |
} |
619 |
if ($child_nt == |
} else { |
620 |
11 |
$attr_node = $od->create_attribute ($name); # return or exception |
621 |
) { |
delete ${$_[0]}->{manakai_content_attribute_list}; |
622 |
$$newChild->{ |
$attr->{''}->{$name} = $attr_node; |
623 |
'child' |
$$attr_node->{owner_element} = $_[0]; |
624 |
} = []; |
Scalar::Util::weaken ($$attr_node->{owner_element}); |
625 |
} else { |
|
626 |
my $v = $$nc_parent->{ |
if ($od->dom_config->get_parameter |
627 |
'child' |
(q<http://suika.fam.cx/www/2006/dom-config/dtd-attribute-type>)) { |
628 |
}; |
my $doctype = $od->doctype; |
629 |
RP: for my $i (0..$#$v) { |
if (defined $doctype) { |
630 |
if ($v->[$i] eq $new_child[0]) { |
my $et = $doctype->get_element_type_definition_node |
631 |
splice @$v, $i, 1, (); |
($_[0]->manakai_tag_name); |
632 |
last RP; |
if (defined $et) { |
633 |
|
my $at = $et->get_attribute_definition_node ($attr_node->manakai_name); |
634 |
|
if (defined $at) { |
635 |
|
$attr_node->manakai_attribute_type ($at->declared_type); |
636 |
|
} |
637 |
} |
} |
|
} # RP |
|
|
} |
|
|
} |
|
|
|
|
|
## -- Rewrite the |parentNode| properties |
|
|
for my $nc (@new_child) { |
|
|
$$nc->{ |
|
|
'parent' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$nc->{ |
|
|
'parent' |
|
|
}); |
|
|
} |
|
|
|
|
|
my $children = $$self->{ |
|
|
'child' |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
## -- Adds to children list |
|
|
push @$children, @new_child; |
|
|
$r = $newChild; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub insert_before ($$;$) { |
|
|
my ($self, $newChild, $refChild) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$self_od = $self-> |
|
|
owner_document |
|
|
; |
|
|
my $child_od = $newChild-> |
|
|
owner_document |
|
|
; |
|
|
my $child_nt = $newChild-> |
|
|
node_type |
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$strict = $self_od-> |
|
|
strict_error_checking |
|
|
; |
|
|
|
|
|
## -- Node Type check |
|
|
my @new_child; |
|
|
if ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
}->{$child_nt}) { |
|
|
push @new_child, $newChild; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
|
unless ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
}->{$cn-> |
|
|
node_type |
|
|
}) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
638 |
} |
} |
|
push @new_child, $cn; |
|
639 |
} |
} |
|
} else { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
640 |
} |
} |
641 |
|
|
642 |
my $nc_parent = @new_child ? $new_child[0]-> |
$attr_node->value ($_[2]); # set or exception |
643 |
parent_node |
$attr_node->specified (1); |
644 |
: |
return undef; |
645 |
|
} # set_attribute |
|
undef |
|
|
; |
|
|
if ($strict) { |
|
|
## -- Wrong-document check |
|
|
unless ($self_od eq $child_od) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
## -- Read-onlyness check |
|
|
if ($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
646 |
|
|
647 |
local $Error::Depth = $Error::Depth - 1; |
sub set_attribute_node ($$) { |
648 |
|
my ($self, $new_attr) = @_; |
649 |
{ |
local $Error::Depth = $Error::Depth + 1; |
650 |
|
my $check = ${$$self->{owner_document}}->{strict_error_checking}; |
651 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1'; |
if ($check and $$self->{owner_document} ne $new_attr->owner_document) { |
652 |
|
local $Error::Depth = $Error::Depth - 1; |
653 |
|
report Message::DOM::DOMException |
654 |
} |
-object => $self, |
655 |
|
-type => 'WRONG_DOCUMENT_ERR'; |
656 |
|
} |
657 |
;} |
|
658 |
|
my $nsuri = $$new_attr->{namespace_uri}; |
659 |
; |
$nsuri = '' unless defined $nsuri; |
660 |
} |
my $ln = $$new_attr->{local_name}; |
661 |
if (@new_child) { |
|
662 |
if ($nc_parent and |
delete $$self->{manakai_content_attribute_list}; |
663 |
$nc_parent-> |
my $attrs = $$self->{attributes}; |
664 |
manakai_read_only |
my $current = $attrs->{$nsuri}->{$ln}; |
665 |
) { |
|
666 |
|
if (defined $$new_attr->{owner_element}) { |
667 |
|
if (defined $current and $current eq $new_attr) { |
668 |
{ |
## No effect |
669 |
|
return undef; # no return value |
670 |
local $Error::Depth = $Error::Depth - 1; |
} else { |
671 |
|
local $Error::Depth = $Error::Depth - 1; |
672 |
{ |
report Message::DOM::DOMException |
673 |
|
-object => $self, |
674 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1'; |
-type => 'INUSE_ATTRIBUTE_ERR'; |
675 |
|
} |
676 |
|
} elsif ($check and $$self->{manakai_read_only}) { |
677 |
} |
report Message::DOM::DOMException |
678 |
|
-object => $self, |
679 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
680 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
681 |
|
} |
682 |
|
|
683 |
|
$attrs->{$nsuri}->{$ln} = $new_attr; |
684 |
|
$$new_attr->{owner_element} = $self; |
685 |
|
Scalar::Util::weaken ($$new_attr->{owner_element}); |
686 |
|
$$new_attr->{specified} = 1; |
687 |
|
|
688 |
|
if (defined $current) { |
689 |
|
delete $$current->{owner_element}; |
690 |
|
$$current->{specified} = 1; |
691 |
|
} |
692 |
|
return $current; |
693 |
|
} # set_attribute_node |
694 |
|
|
695 |
;} |
*set_attribute_node_ns = \&set_attribute_node; |
696 |
|
|
697 |
; |
## The second parameter only supports manakai extended way |
698 |
} |
## to specify qualified name - "[$prefix, $local_name]" ## TODO: Document |
699 |
|
sub set_attribute_ns ($$$$) { |
700 |
|
my $prefix; |
701 |
|
my $lname; |
702 |
|
if (ref $_[2] eq 'ARRAY') { |
703 |
|
($prefix, $lname) = @{$_[2]}; |
704 |
|
} else { |
705 |
|
($prefix, $lname) = split /:/, $_[2], 2; |
706 |
|
($prefix, $lname) = (undef, $prefix) unless defined $lname; |
707 |
|
} |
708 |
|
|
709 |
|
my $od = ${$_[0]}->{owner_document}; |
710 |
|
if ($$od->{strict_error_checking}) { |
711 |
|
if (${$_[0]}->{manakai_read_only}) { |
712 |
|
report Message::DOM::DOMException |
713 |
|
-object => $_[0], |
714 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
715 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
716 |
} |
} |
717 |
} |
} |
718 |
|
|
719 |
## -- Insert at... |
my $attr = ${$_[0]}->{attributes}; |
720 |
my $index = -1; # last |
my $attr_node = $attr->{defined $_[1] ? ''.$_[1] : ''}->{$lname}; |
721 |
|
|
722 |
|
local $Error::Depth = $Error::Depth + 1; |
723 |
{ |
if (defined $attr_node) { |
724 |
|
if ($$od->{strict_error_checking}) { |
725 |
|
$od->create_attribute_ns ($_[1], [$prefix, $lname]); # name exception |
726 |
# tc:ForAppendChild & tc:ForReplaceChild |
} |
727 |
if (defined $refChild) { |
} else { |
728 |
if ($refChild eq $newChild) { |
$attr_node = $od->create_attribute_ns |
729 |
|
($_[1], [$prefix, $lname]); # or exception |
730 |
|
delete ${$_[0]}->{manakai_content_attribute_list}; |
731 |
{ |
$attr->{defined $_[1] ? ''.$_[1] : ''}->{$lname} = $attr_node; |
732 |
|
$$attr_node->{owner_element} = $_[0]; |
733 |
|
Scalar::Util::weaken ($$attr_node->{owner_element}); |
734 |
{ |
|
735 |
|
if ($od->dom_config->get_parameter |
736 |
local $Error::Depth = $Error::Depth - 1; |
(q<http://suika.fam.cx/www/2006/dom-config/dtd-attribute-type>)) { |
737 |
|
my $doctype = $od->doctype; |
738 |
{ |
if (defined $doctype) { |
739 |
|
my $et = $doctype->get_element_type_definition_node |
740 |
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#insert-before-itself', 'rdata' => $refChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1'; |
($_[0]->manakai_tag_name); |
741 |
|
if (defined $et) { |
742 |
|
my $at = $et->get_attribute_definition_node ($attr_node->manakai_name); |
743 |
} |
if (defined $at) { |
744 |
|
$attr_node->manakai_attribute_type ($at->declared_type); |
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
my $cns = $self-> |
|
|
child_nodes |
|
|
; |
|
|
my $cnsl = @$cns; |
|
|
C: { |
|
|
$index = 0; |
|
|
for my $i (0..($cnsl-1)) { |
|
|
my $cn = $cns->[$i]; |
|
|
if ($cn eq $refChild) { |
|
|
$index += $i; |
|
|
last C; |
|
|
} elsif ($cn eq $newChild) { |
|
|
$index = -1; # offset |
|
745 |
} |
} |
746 |
} |
} |
747 |
|
} |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'refChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $refChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
; |
|
|
} # C |
|
|
} else { # |oldChild| is not defined |
|
|
|
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; # FOR !tc:ForAppendChild |
|
|
|
|
|
## -- Removes from parent |
|
|
if ($nc_parent) { |
|
|
if ($child_nt == |
|
|
11 |
|
|
) { |
|
|
$$newChild->{ |
|
|
'child' |
|
|
} = []; |
|
|
} else { |
|
|
my $v = $$nc_parent->{ |
|
|
'child' |
|
|
}; |
|
|
RP: for my $i (0..$#$v) { |
|
|
if ($v->[$i] eq $new_child[0]) { |
|
|
splice @$v, $i, 1, (); |
|
|
last RP; |
|
|
} |
|
|
} # RP |
|
748 |
} |
} |
749 |
} |
} |
750 |
|
|
751 |
## -- Rewrite the |parentNode| properties |
$attr_node->value ($_[3]); # set or exception |
752 |
for my $nc (@new_child) { |
$attr_node->prefix ($prefix); |
753 |
$$nc->{ |
$attr_node->specified (1); |
754 |
'parent' |
return undef; |
755 |
} = $self; |
} # set_attribute_ns |
756 |
Scalar::Util::weaken ($$nc->{ |
|
757 |
'parent' |
sub set_id_attribute ($$$) { |
758 |
}); |
if (${${$_[0]}->{owner_document}}->{strict_error_checking} and |
759 |
|
${$_[0]}->{manakai_read_only}) { |
760 |
|
report Message::DOM::DOMException |
761 |
|
-object => $_[0], |
762 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
763 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
764 |
|
} |
765 |
|
|
766 |
|
my $attr = $_[0]->get_attribute_node ($_[1]); |
767 |
|
if (not defined $attr) { |
768 |
|
report Message::DOM::DOMException |
769 |
|
-object => $_[0], |
770 |
|
-type => 'NOT_FOUND_ERR', |
771 |
|
-subtype => 'NOT_CHILD_ERR'; |
772 |
|
} else { |
773 |
|
local $Error::Depth = $Error::Depth + 1; |
774 |
|
$attr->is_id ($_[2]); # or exception |
775 |
|
} |
776 |
|
return; |
777 |
|
} # set_id_attribute |
778 |
|
|
779 |
|
sub set_id_attribute_ns ($$$$) { |
780 |
|
if (${${$_[0]}->{owner_document}}->{strict_error_checking} and |
781 |
|
${$_[0]}->{manakai_read_only}) { |
782 |
|
report Message::DOM::DOMException |
783 |
|
-object => $_[0], |
784 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
785 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
786 |
|
} |
787 |
|
|
788 |
|
my $attr = $_[0]->get_attribute_node_ns ($_[1], $_[2]); |
789 |
|
if (not defined $attr) { |
790 |
|
report Message::DOM::DOMException |
791 |
|
-object => $_[0], |
792 |
|
-type => 'NOT_FOUND_ERR', |
793 |
|
-subtype => 'NOT_CHILD_ERR'; |
794 |
|
} else { |
795 |
|
local $Error::Depth = $Error::Depth + 1; |
796 |
|
$attr->is_id ($_[2]); |
797 |
|
} |
798 |
|
return; |
799 |
|
} # set_id_attribute_ns |
800 |
|
|
801 |
|
sub set_id_attribute_node ($$$$) { |
802 |
|
if (${${$_[0]}->{owner_document}}->{strict_error_checking} and |
803 |
|
${$_[0]}->{manakai_read_only}) { |
804 |
|
report Message::DOM::DOMException |
805 |
|
-object => $_[0], |
806 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
807 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
808 |
|
} |
809 |
|
|
810 |
|
my $oe = $_[1]->owner_element; |
811 |
|
if ($oe ne $_[0]) { |
812 |
|
report Message::DOM::DOMException |
813 |
|
-object => $_[0], |
814 |
|
-type => 'NOT_FOUND_ERR', |
815 |
|
-subtype => 'NOT_CHILD_ERR'; |
816 |
|
} else { |
817 |
|
local $Error::Depth = $Error::Depth + 1; |
818 |
|
$_[1]->is_id ($_[2]); |
819 |
} |
} |
820 |
|
return; |
821 |
|
} # set_id_attribute_node |
822 |
|
|
823 |
my $children = $$self->{ |
package Message::IF::Element; |
|
'child' |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
## -- Adds to children list |
|
|
if ($index == -1) { |
|
|
push @$children, @new_child; |
|
|
} else { |
|
|
splice @$children, $index, 0, @new_child; |
|
|
} |
|
|
$r = $newChild; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub replace_child ($$$) { |
|
|
my ($self, $newChild, $oldChild) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
824 |
|
|
825 |
my |
package Message::DOM::Document; |
|
$self_od = $self-> |
|
|
owner_document |
|
|
; |
|
|
my $child_od = $newChild-> |
|
|
owner_document |
|
|
; |
|
|
my $child_nt = $newChild-> |
|
|
node_type |
|
|
; |
|
826 |
|
|
827 |
|
sub create_element ($$) { |
828 |
{ |
my $self = $_[0]; |
829 |
|
if ($$self->{strict_error_checking}) { |
830 |
|
my $xv = $self->xml_version; |
831 |
{ |
## TODO: HTML Document ?? |
832 |
|
if (defined $xv) { |
833 |
local $Error::Depth = $Error::Depth + 1; |
if ($xv eq '1.0' and |
834 |
|
$_[1] =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) { |
835 |
{ |
# |
836 |
|
} elsif ($xv eq '1.1' and |
837 |
|
$_[1] =~ /\A\p{InXMLNameStartChar11}\p{InXMLNameChar11}*\z/) { |
838 |
my |
# |
839 |
$strict = $self_od-> |
} else { |
840 |
strict_error_checking |
report Message::DOM::DOMException |
841 |
; |
-object => $self, |
842 |
|
-type => 'INVALID_CHARACTER_ERR', |
843 |
## -- Node Type check |
-subtype => 'MALFORMED_NAME_ERR'; |
|
my @new_child; |
|
|
if ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
}->{$child_nt}) { |
|
|
push @new_child, $newChild; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
|
unless ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
}->{$cn-> |
|
|
node_type |
|
|
}) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
844 |
} |
} |
|
push @new_child, $cn; |
|
845 |
} |
} |
|
} else { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
846 |
} |
} |
847 |
|
## TODO: HTML5 |
848 |
my $nc_parent = @new_child ? $new_child[0]-> |
|
849 |
parent_node |
my $r = Message::DOM::Element->____new ($self, undef, undef, $_[1]); |
850 |
: |
|
851 |
|
## -- Default attributes |
852 |
undef |
{ |
853 |
; |
local $Error::Depth = $Error::Depth + 1; |
854 |
if ($strict) { |
my $cfg = $self->dom_config; |
855 |
## -- Wrong-document check |
return $r |
856 |
unless ($self_od eq $child_od) { |
unless $cfg->get_parameter |
857 |
|
(q<http://suika.fam.cx/www/2006/dom-config/dtd-default-attribute>); |
858 |
|
|
859 |
{ |
my $doctype = $self->doctype; |
860 |
|
return $r unless defined $doctype; |
861 |
local $Error::Depth = $Error::Depth - 1; |
|
862 |
|
my $et = $doctype->get_element_type_definition_node ($_[1]); |
863 |
{ |
return $r unless defined $et; |
864 |
|
|
865 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
my $orig_strict = $self->strict_error_checking; |
866 |
|
$self->strict_error_checking (0); |
867 |
|
|
868 |
} |
my %gattr; |
869 |
|
my %has_attr; |
870 |
|
my %pfx_to_uri; |
871 |
;} |
my $copy_asis = $cfg->get_parameter |
872 |
|
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree>); |
873 |
; |
$cfg->set_parameter |
874 |
} |
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree> => 1); |
875 |
|
|
876 |
## -- Read-onlyness check |
for my $at (@{$et->attribute_definitions}) { |
877 |
if ($self-> |
my $at_default = $at->default_type; |
878 |
manakai_read_only |
if ($at_default == 4 or $at_default == 1) { |
879 |
) { |
# EXPLICIT_DEFAULT, FIXED_DEFAULT |
880 |
|
my ($nn1, $nn2) = split /:/, $at->node_name; |
881 |
|
if (defined $nn2) { # prefixed |
882 |
{ |
if ($nn1 eq 'xmlns') { |
883 |
|
## TODO: NCName check, prefix check and NSURI check |
884 |
local $Error::Depth = $Error::Depth - 1; |
my $attr = $self->create_attribute_ns |
885 |
|
(q<http://www.w3.org/2000/xmlns/>, [$nn1, $nn2]); |
886 |
{ |
for my $at_child (@{$at->child_nodes}) { |
887 |
|
$attr->append_child ($at_child->clone_node (1)); |
888 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1'; |
} |
889 |
|
$attr->manakai_attribute_type ($at->declared_type); |
890 |
|
my $nsuri = $attr->value; |
891 |
} |
## TODO: Namespace well-formedness check (NSURI), v1.1 chk |
892 |
|
$pfx_to_uri{$nn2} = $nsuri; |
893 |
|
$r->set_attribute_node_ns ($attr); |
894 |
;} |
## NOTE: This method changes |specified| flag |
895 |
|
$attr->specified (0); |
896 |
; |
$has_attr{q<http://www.w3.org/2000/xmlns/>}->{$nn2} = 1; |
897 |
} |
} else { |
898 |
if (@new_child) { |
## TODO: NCName check |
899 |
if ($nc_parent and |
$gattr{$nn1}->{$nn2} = $at; |
900 |
$nc_parent-> |
} |
901 |
manakai_read_only |
} else { # no prefixed |
902 |
) { |
my $attr; |
903 |
|
if ($nn1 eq 'xmlns') { |
904 |
|
$attr = $self->create_attribute_ns |
905 |
{ |
(q<http://www.w3.org/2000/xmlns/>, 'xmlns'); |
906 |
|
$has_attr{q<http://www.w3.org/2000/xmlns/>}->{xmlns} = 1; |
907 |
local $Error::Depth = $Error::Depth - 1; |
} else { |
908 |
|
$attr = $self->create_attribute_ns (undef, $nn1); |
909 |
{ |
## TODO: NCName check |
910 |
|
} |
911 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1'; |
for my $at_child (@{$at->child_nodes}) { |
912 |
|
$attr->append_child ($at_child->clone_node (1)); |
913 |
|
} |
914 |
} |
$attr->manakai_attribute_type ($at->declared_type); |
915 |
|
## TODO: Namespace well-formedness check (NSURI) |
916 |
|
$r->set_attribute_node_ns ($attr); |
917 |
;} |
## NOTE: This method changes |specified| flag |
918 |
|
$attr->specified (0); |
919 |
; |
} |
920 |
} |
} |
921 |
} |
} # attrdefs |
922 |
} |
for my $pfx (keys %gattr) { |
923 |
|
my $nsuri = $pfx_to_uri{$pfx}; |
924 |
## -- Insert at... |
unless (defined $nsuri) { |
925 |
my $index = -1; # last |
## TODO: Namespace well-formedness error |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
# tc:ForAppendChild & tc:ForReplaceChild |
|
|
if (defined $oldChild) { |
|
|
if ($oldChild eq $newChild) { |
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#replace-by-itself', 'rdata' => $oldChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
926 |
} |
} |
927 |
|
LN: for my $ln (keys %{$gattr{$pfx}}) { |
928 |
my $cns = $self-> |
if ($has_attr{defined $nsuri ? $nsuri : ''}->{$ln}) { |
929 |
child_nodes |
## TODO: Namespace well-formedness error |
930 |
; |
next LN; |
|
my $cnsl = @$cns; |
|
|
C: { |
|
|
$index = 0; |
|
|
for my $i (0..($cnsl-1)) { |
|
|
my $cn = $cns->[$i]; |
|
|
if ($cn eq $oldChild) { |
|
|
$index += $i; |
|
|
last C; |
|
|
} elsif ($cn eq $newChild) { |
|
|
$index = -1; # offset |
|
|
} |
|
931 |
} |
} |
932 |
|
## TODO: NCName check, prefix check and NSURI check |
933 |
|
my $at = $gattr{$pfx}->{$ln}; |
934 |
; |
my $attr = $self->create_attribute_ns ($nsuri, [$pfx, $ln]); |
935 |
|
for my $at_child (@{$at->child_nodes}) { |
936 |
|
$attr->append_child ($at_child->clone_node (1)); |
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} # C |
|
|
} else { # |oldChild| is not defined |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; # FOR !tc:ForAppendChild |
|
|
|
|
|
## -- Removes from parent |
|
|
if ($nc_parent) { |
|
|
if ($child_nt == |
|
|
11 |
|
|
) { |
|
|
$$newChild->{ |
|
|
'child' |
|
|
} = []; |
|
|
} else { |
|
|
my $v = $$nc_parent->{ |
|
|
'child' |
|
|
}; |
|
|
RP: for my $i (0..$#$v) { |
|
|
if ($v->[$i] eq $new_child[0]) { |
|
|
splice @$v, $i, 1, (); |
|
|
last RP; |
|
937 |
} |
} |
938 |
} # RP |
$attr->manakai_attribute_type ($at->declared_type); |
939 |
} |
$r->set_attribute_node_ns ($attr); |
940 |
|
## NOTE: This method changes |specified| flag |
941 |
|
$attr->specified (0); |
942 |
|
$has_attr{defined $nsuri ? $nsuri : ''}->{$ln} = 1; |
943 |
|
} # LN |
944 |
|
} # pfx |
945 |
|
$cfg->set_parameter |
946 |
|
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree> => $copy_asis); |
947 |
|
$self->strict_error_checking ($orig_strict); |
948 |
} |
} |
949 |
|
|
950 |
## -- Rewrite the |parentNode| properties |
return $r; |
951 |
for my $nc (@new_child) { |
} # create_element |
|
$$nc->{ |
|
|
'parent' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$nc->{ |
|
|
'parent' |
|
|
}); |
|
|
} |
|
|
|
|
|
my $children = $$self->{ |
|
|
'child' |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
## -- Replaces the node |
|
|
splice @$children, $index, 1, @new_child; |
|
|
CORE::delete $$oldChild->{ |
|
|
'parent' |
|
|
}; |
|
|
$r = $oldChild; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub node_name ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$prefix = $$self->{ |
|
|
'pfx' |
|
|
}; |
|
|
my $lname = $$self->{ |
|
|
'ln' |
|
|
}; |
|
|
$r = defined $prefix ? $$prefix.':'.$$lname : $$lname; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'node_name'; |
|
|
} |
|
|
} |
|
|
sub name ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$prefix = $$self->{ |
|
|
'pfx' |
|
|
}; |
|
|
my $lname = $$self->{ |
|
|
'ln' |
|
|
}; |
|
|
$r = defined $prefix ? $$prefix.':'.$$lname : $$lname; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'name'; |
|
|
} |
|
|
} |
|
|
sub node_value ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$r = ''; |
|
|
for my $child (@{$self-> |
|
|
child_nodes |
|
|
}) { |
|
|
if ($child-> |
|
|
node_type |
|
|
== |
|
|
|
|
|
5 |
|
|
) { |
|
|
my $v = $child-> |
|
|
text_content |
|
|
; |
|
|
$v =~ s/[\x09\x0A\x0D]/ /; |
|
|
$r .= $v; |
|
|
} else { |
|
|
$r .= $child-> |
|
|
text_content |
|
|
; |
|
|
} |
|
|
} # childNodes |
|
|
my $vt = $$self->{ |
|
|
'at' |
|
|
}; |
|
|
unless (not defined $vt or |
|
|
$vt == |
|
|
0 or |
|
|
|
|
|
$vt == |
|
|
11 or |
|
|
|
|
|
$vt == |
|
|
1 |
|
|
) { |
|
|
$r =~ s/\A\x20+//; |
|
|
$r =~ s/\x20+\z//; |
|
|
$r =~ s/\x20+/ /g; |
|
|
} |
|
|
|
|
|
if (defined $vt and $vt == |
|
|
2 and |
|
|
|
|
|
$self-> |
|
|
owner_document |
|
|
-> |
|
|
dom_config |
|
|
|
|
|
-> |
|
|
get_parameter |
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/xml-id' |
|
|
)) { |
|
|
$r =~ s/[\x09\x0A\x0D\x20]+/ /g; |
|
|
$r =~ s/\A //; |
|
|
$r =~ s/ \z//; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self, $given) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
for my $__old_child (@{${$self}->{ |
|
|
'child' |
|
|
}}) { |
|
|
CORE::delete $$__old_child->{ |
|
|
'parent' |
|
|
}; |
|
|
} |
|
|
|
|
|
my @__new_children; |
|
|
if (defined $given and length $given) { |
|
|
my $__text = $self->owner_document-> |
|
|
create_text_node |
|
|
($given); |
|
|
push @__new_children, $__text; |
|
|
$$__text->{ |
|
|
'parent' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$__text->{ |
|
|
'parent' |
|
|
}); |
|
|
} |
|
|
|
|
|
${$self}->{ |
|
|
'child' |
|
|
} = \@__new_children; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
sub manakai_append_text ($$) { |
|
|
my ($self, $string) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$lc = $self-> |
|
|
last_child |
|
|
; |
|
|
if (defined $lc and |
|
|
$lc-> |
|
|
node_type |
|
|
== |
|
|
3 |
|
|
) { |
|
|
$lc-> |
|
|
manakai_append_text |
|
|
|
|
|
(ref $string eq 'SCALAR' ? $string : \$string); |
|
|
} else { |
|
|
my $text = $self-> |
|
|
owner_document |
|
|
|
|
|
-> |
|
|
create_text_node |
|
|
|
|
|
(ref $string eq 'SCALAR' ? $$string : $string); |
|
|
$self-> |
|
|
append_child |
|
|
($text); |
|
|
} |
|
|
$r = $self; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub get_feature ($$$) { |
|
|
my ($self, $feature, $version) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$feature = lc $feature; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$version = '' unless defined $version; |
|
|
|
|
|
|
|
|
} |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$feature =~ s/^\+//; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($Message::Util::AutoLoad::Registry::Feature->{$feature}->{$version}) { |
|
|
$r = $self; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
unless (defined $r) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$r = $self->SUPER::get_feature ($feature, $version); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
952 |
|
|
953 |
} |
sub create_element_ns ($$$) { |
954 |
$r} |
my $self = $_[0]; |
955 |
sub base_uri ($;$) { |
my ($prefix, $lname); |
956 |
if (@_ == 1) {my ($self) = @_; |
if (ref $_[2] eq 'ARRAY') { |
957 |
my $r = ''; |
($prefix, $lname) = @{$_[2]}; |
958 |
|
} else { |
959 |
{ |
($prefix, $lname) = split /:/, $_[2], 2; |
960 |
|
($prefix, $lname) = (undef, $prefix) unless defined $lname; |
961 |
|
} |
962 |
{ |
my $nsuri = defined $_[1] ? $_[1] eq '' ? undef : $_[1] : undef; |
963 |
|
|
964 |
local $Error::Depth = $Error::Depth + 1; |
if ($$self->{strict_error_checking}) { |
965 |
|
my $xv = $self->xml_version; |
966 |
{ |
## TODO: HTML Document ?? (NOT_SUPPORTED_ERR is different from what Web browsers do) |
967 |
|
if (defined $xv) { |
968 |
|
if ($xv eq '1.0') { |
969 |
my |
if (ref $_[2] eq 'ARRAY' or |
970 |
$oe = $self-> |
$_[2] =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) { |
971 |
owner_element |
if (defined $prefix) { |
972 |
; |
if ($prefix =~ /\A\p{InXML_NCNameStartChar10}\p{InXMLNCNameChar10}*\z/) { |
973 |
if ($oe) { |
# |
974 |
my $ln = $self->local_name; |
} else { |
975 |
my $nsuri = $self->namespace_uri; |
report Message::DOM::DOMException |
976 |
if (($ln eq 'base' and defined $nsuri and $nsuri eq |
-object => $self, |
977 |
'http://www.w3.org/XML/1998/namespace' |
-type => 'NAMESPACE_ERR', |
978 |
) or |
-subtype => 'MALFORMED_QNAME_ERR'; |
979 |
($ln eq 'xml:base' and not defined $nsuri)) { |
} |
980 |
my $oep = $oe-> |
} |
981 |
parent_node |
if ($lname =~ /\A\p{InXML_NCNameStartChar10}\p{InXMLNCNameChar10}*\z/) { |
982 |
; |
# |
983 |
if ($oep) { |
} else { |
984 |
$r = $oep-> |
report Message::DOM::DOMException |
985 |
base_uri |
-object => $self, |
986 |
; |
-type => 'NAMESPACE_ERR', |
987 |
|
-subtype => 'MALFORMED_QNAME_ERR'; |
988 |
|
} |
989 |
|
} else { |
990 |
|
report Message::DOM::DOMException |
991 |
|
-object => $self, |
992 |
|
-type => 'INVALID_CHARACTER_ERR', |
993 |
|
-subtype => 'MALFORMED_NAME_ERR'; |
994 |
|
} |
995 |
|
} elsif ($xv eq '1.1') { |
996 |
|
if (ref $_[2] eq 'ARRAY' or |
997 |
|
$_[2] =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) { |
998 |
|
if (defined $prefix) { |
999 |
|
if ($prefix =~ /\A\p{InXMLNCNameStartChar11}\p{InXMLNCNameChar11}*\z/) { |
1000 |
|
# |
1001 |
|
} else { |
1002 |
|
report Message::DOM::DOMException |
1003 |
|
-object => $self, |
1004 |
|
-type => 'NAMESPACE_ERR', |
1005 |
|
-subtype => 'MALFORMED_QNAME_ERR'; |
1006 |
|
} |
1007 |
|
} |
1008 |
|
if ($lname =~ /\A\p{InXMLNCNameStartChar11}\p{InXMLNCNameChar11}*\z/) { |
1009 |
|
# |
1010 |
|
} else { |
1011 |
|
report Message::DOM::DOMException |
1012 |
|
-object => $self, |
1013 |
|
-type => 'NAMESPACE_ERR', |
1014 |
|
-subtype => 'MALFORMED_QNAME_ERR'; |
1015 |
|
} |
1016 |
|
} else { |
1017 |
|
report Message::DOM::DOMException |
1018 |
|
-object => $self, |
1019 |
|
-type => 'INVALID_CHARACTER_ERR', |
1020 |
|
-subtype => 'MALFORMED_NAME_ERR'; |
1021 |
|
} |
1022 |
} else { |
} else { |
1023 |
$r = $self-> |
die "create_attribute_ns: XML version |$xv| is not supported"; |
|
owner_document |
|
|
-> |
|
|
base_uri |
|
|
; |
|
1024 |
} |
} |
|
} else { |
|
|
$r = $oe-> |
|
|
base_uri |
|
|
; |
|
1025 |
} |
} |
|
} else { |
|
|
$r = $self-> |
|
|
owner_document |
|
|
-> |
|
|
base_uri |
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'base_uri'; |
|
|
} |
|
|
} |
|
|
sub owner_element ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = $$self->{ |
|
|
'owner' |
|
|
}; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'owner_element'; |
|
|
} |
|
|
} |
|
|
sub specified ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = 0; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = $$self->{ |
|
|
'specified' |
|
|
}; |
|
|
unless ($r) { |
|
|
unless (defined $$self->{ |
|
|
'owner' |
|
|
}) { |
|
|
$r = |
|
|
1 |
|
|
; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self, $given) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
unless ($given) { |
|
|
$given = 1 unless defined $$self->{ |
|
|
'owner' |
|
|
}; |
|
|
} |
|
|
$$self->{ |
|
|
'specified' |
|
|
} = $given; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
sub value ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$r = ''; |
|
|
for my $child (@{$self-> |
|
|
child_nodes |
|
|
}) { |
|
|
if ($child-> |
|
|
node_type |
|
|
== |
|
|
|
|
|
5 |
|
|
) { |
|
|
my $v = $child-> |
|
|
text_content |
|
|
; |
|
|
$v =~ s/[\x09\x0A\x0D]/ /; |
|
|
$r .= $v; |
|
|
} else { |
|
|
$r .= $child-> |
|
|
text_content |
|
|
; |
|
|
} |
|
|
} # childNodes |
|
|
my $vt = $$self->{ |
|
|
'at' |
|
|
}; |
|
|
unless (not defined $vt or |
|
|
$vt == |
|
|
0 or |
|
|
|
|
|
$vt == |
|
|
11 or |
|
|
|
|
|
$vt == |
|
|
1 |
|
|
) { |
|
|
$r =~ s/\A\x20+//; |
|
|
$r =~ s/\x20+\z//; |
|
|
$r =~ s/\x20+/ /g; |
|
|
} |
|
|
|
|
|
if (defined $vt and $vt == |
|
|
2 and |
|
|
|
|
|
$self-> |
|
|
owner_document |
|
|
-> |
|
|
dom_config |
|
|
|
|
|
-> |
|
|
get_parameter |
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/xml-id' |
|
|
)) { |
|
|
$r =~ s/[\x09\x0A\x0D\x20]+/ /g; |
|
|
$r =~ s/\A //; |
|
|
$r =~ s/ \z//; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self, $given) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
for my $__old_child (@{${$self}->{ |
|
|
'child' |
|
|
}}) { |
|
|
CORE::delete $$__old_child->{ |
|
|
'parent' |
|
|
}; |
|
|
} |
|
|
|
|
|
my @__new_children; |
|
|
if (defined $given and length $given) { |
|
|
my $__text = $self->owner_document-> |
|
|
create_text_node |
|
|
($given); |
|
|
push @__new_children, $__text; |
|
|
$$__text->{ |
|
|
'parent' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$__text->{ |
|
|
'parent' |
|
|
}); |
|
|
} |
|
|
|
|
|
${$self}->{ |
|
|
'child' |
|
|
} = \@__new_children; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
sub schema_type_info ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$type = $$self->{ |
|
|
'at' |
|
|
}; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$v = $type || 0; |
|
|
$r = bless \$v, |
|
|
'Message::DOM::Element::ManakaiDOMDTDTypeInfo' |
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMAttr', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'schema_type_info'; |
|
|
} |
|
|
} |
|
|
sub is_id ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = 0; |
|
|
|
|
|
{ |
|
|
|
|
|
T: |
|
|
{ |
|
|
## DTD Attribute Type |
|
|
my $type = $$self->{ |
|
|
'at' |
|
|
}; |
|
|
if (defined $type and $type == |
|
|
2 |
|
|
) { |
|
|
$r = |
|
|
1 |
|
|
; |
|
|
last T; |
|
|
} |
|
|
|
|
|
## User-determined ID |
|
|
my $udid = $$self->{ |
|
|
'isudid' |
|
|
}; |
|
|
if ($udid) { |
|
|
$r = |
|
|
1 |
|
|
; |
|
|
last T; |
|
|
} |
|
|
|
|
|
## Application-determined ID |
|
|
my $nsuri = $self-> |
|
|
namespace_uri |
|
|
; |
|
|
my $ln = $self-> |
|
|
local_name |
|
|
; |
|
|
if (defined $nsuri and $nsuri eq |
|
|
'http://www.w3.org/XML/1998/namespace' and |
|
|
|
|
|
$ln eq 'id') { |
|
|
$r = |
|
|
1 |
|
|
; |
|
|
last T; |
|
|
} elsif (not defined $nsuri and $ln eq 'xml:id') { |
|
|
$r = |
|
|
1 |
|
|
; |
|
|
last T; |
|
|
} |
|
|
} # T |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self, $given) = @_; |
|
1026 |
|
|
1027 |
{ |
if (defined $prefix) { |
1028 |
|
if (not defined $nsuri) { |
1029 |
|
report Message::DOM::DOMException |
1030 |
{ |
-object => $self, |
1031 |
|
-type => 'NAMESPACE_ERR', |
1032 |
if |
-subtype => 'PREFIXED_NULLNS_ERR'; |
1033 |
($self-> |
} elsif ($prefix eq 'xml' and |
1034 |
manakai_read_only |
$nsuri ne q<http://www.w3.org/XML/1998/namespace>) { |
1035 |
) { |
report Message::DOM::DOMException |
1036 |
|
-object => $self, |
1037 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError'; |
-type => 'NAMESPACE_ERR', |
1038 |
|
-subtype => 'XMLPREFIX_NONXMLNS_ERR'; |
1039 |
; |
} elsif ($prefix eq 'xmlns' and |
1040 |
} |
$nsuri ne q<http://www.w3.org/2000/xmlns/>) { |
1041 |
|
report Message::DOM::DOMException |
1042 |
|
-object => $self, |
1043 |
} |
-type => 'NAMESPACE_ERR', |
1044 |
|
-subtype => 'XMLNSPREFIX_NONXMLNSNS_ERR'; |
1045 |
; |
} elsif ($nsuri eq q<http://www.w3.org/2000/xmlns/> and |
1046 |
$$self->{ |
$prefix ne 'xmlns') { |
1047 |
'isudid' |
report Message::DOM::DOMException |
1048 |
} = $given; |
-object => $self, |
1049 |
|
-type => 'NAMESPACE_ERR', |
1050 |
|
-subtype => 'NONXMLNSPREFIX_XMLNSNS_ERR'; |
1051 |
} |
} |
1052 |
} |
} else { # no prefix |
1053 |
} |
if ($lname eq 'xmlns' and |
1054 |
sub manakai_attribute_type ($;$) { |
(not defined $nsuri or $nsuri ne q<http://www.w3.org/2000/xmlns/>)) { |
1055 |
if (@_ == 1) {my ($self) = @_; |
report Message::DOM::DOMException |
1056 |
my $r = 0; |
-object => $self, |
1057 |
|
-type => 'NAMESPACE_ERR', |
1058 |
{ |
-subtype => 'XMLNS_NONXMLNSNS_ERR'; |
1059 |
|
} elsif (not defined $nsuri) { |
1060 |
|
# |
1061 |
$r = $$self->{ |
} elsif ($nsuri eq q<http://www.w3.org/2000/xmlns/> and |
1062 |
'at' |
$lname ne 'xmlns') { |
1063 |
}; |
report Message::DOM::DOMException |
1064 |
$r = |
-object => $self, |
1065 |
0 unless |
-type => 'NAMESPACE_ERR', |
1066 |
defined $r; |
-subtype => 'NONXMLNSPREFIX_XMLNSNS_ERR'; |
1067 |
|
} |
1068 |
|
} |
1069 |
} |
} |
1070 |
$r; |
|
1071 |
} else {my ($self, $given) = @_; |
## -- Choose the most apppropriate class for the element |
1072 |
|
my $class = 'Message::DOM::Element'; |
1073 |
{ |
if (defined $nsuri) { |
1074 |
|
if ($nsuri eq q<http://www.w3.org/2005/Atom>) { |
1075 |
|
require Message::DOM::Atom::AtomElement; |
1076 |
{ |
$class = { |
1077 |
|
author => 'Message::DOM::Atom::AtomElement::AtomPersonConstruct', |
1078 |
if |
category => 'Message::DOM::Atom::AtomElement::AtomCategoryElement', |
1079 |
($self-> |
content => 'Message::DOM::Atom::AtomElement::AtomContentElement', |
1080 |
manakai_read_only |
contributor => 'Message::DOM::Atom::AtomElement::AtomPersonConstruct', |
1081 |
) { |
entry => 'Message::DOM::Atom::AtomElement::AtomEntryElement', |
1082 |
|
feed => 'Message::DOM::Atom::AtomElement::AtomFeedElement', |
1083 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError'; |
generator => 'Message::DOM::Atom::AtomElement::AtomGeneratorElement', |
1084 |
|
link => 'Message::DOM::Atom::AtomElement::AtomLinkElement', |
1085 |
; |
published => 'Message::DOM::Atom::AtomElement::AtomDateConstruct', |
1086 |
} |
rights => 'Message::DOM::Atom::AtomElement::AtomTextConstruct', |
1087 |
|
source => 'Message::DOM::Atom::AtomElement::AtomSourceElement', |
1088 |
|
subtitle => 'Message::DOM::Atom::AtomElement::AtomTextConstruct', |
1089 |
} |
summary => 'Message::DOM::Atom::AtomElement::AtomTextConstruct', |
1090 |
|
title => 'Message::DOM::Atom::AtomElement::AtomTextConstruct', |
1091 |
; |
updated => 'Message::DOM::Atom::AtomElement::AtomDateConstruct', |
1092 |
$$self->{ |
}->{$lname} || 'Message::DOM::Atom::AtomElement'; |
1093 |
'at' |
} |
1094 |
} = $given; |
} |
1095 |
|
|
1096 |
|
my $r = $class->____new ($self, $nsuri, $prefix, $lname); |
1097 |
} |
|
1098 |
} |
## -- Default attributes |
1099 |
} |
{ |
1100 |
$Message::DOM::DOMFeature::ClassInfo->{q<Message::DOM::Element::ManakaiDOMAttr>}->{has_feature} = {'core', |
local $Error::Depth = $Error::Depth + 1; |
1101 |
{'', |
my $cfg = $self->dom_config; |
1102 |
'1', |
return $r |
1103 |
'1.0', |
unless $cfg->get_parameter |
1104 |
'1', |
(q<http://suika.fam.cx/www/2006/dom-config/dtd-default-attribute>); |
1105 |
'2.0', |
|
1106 |
'1', |
my $doctype = $self->doctype; |
1107 |
'3.0', |
return $r unless defined $doctype; |
1108 |
'1'}, |
|
1109 |
'xml', |
my $et = $doctype->get_element_type_definition_node |
1110 |
{'', |
(defined $prefix ? $prefix . ':' . $lname : $lname); |
1111 |
'1', |
return $r unless defined $et; |
1112 |
'1.0', |
|
1113 |
'1', |
my $orig_strict = $self->strict_error_checking; |
1114 |
'2.0', |
$self->strict_error_checking (0); |
1115 |
'1', |
|
1116 |
'3.0', |
my %gattr; |
1117 |
'1'}, |
my %has_attr; |
1118 |
'xmlversion', |
my %pfx_to_uri; |
1119 |
{'', |
my $copy_asis = $cfg->get_parameter |
1120 |
'1', |
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree>); |
1121 |
'1.0', |
$cfg->set_parameter |
1122 |
'1', |
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree> => 1); |
1123 |
'1.1', |
|
1124 |
'1'}}; |
for my $at (@{$et->attribute_definitions}) { |
1125 |
$Message::DOM::ClassPoint{q<Message::DOM::Element::ManakaiDOMAttr>} = 14.1; |
my $at_default = $at->default_type; |
1126 |
package Message::DOM::IF::TypeInfo; |
if ($at_default == 4 or $at_default == 1) { |
1127 |
our $VERSION = 20061231.0930; |
# EXPLICIT_DEFAULT, FIXED_DEFAULT |
1128 |
sub DERIVATION_RESTRICTION () { |
my ($nn1, $nn2) = split /:/, $at->node_name; |
1129 |
1} |
if (defined $nn2) { # prefixed |
1130 |
sub DERIVATION_EXTENSION () { |
if ($nn1 eq 'xmlns') { |
1131 |
2} |
## TODO: NCName check, prefix check and NSURI check |
1132 |
sub DERIVATION_UNION () { |
my $attr = $self->create_attribute_ns |
1133 |
4} |
(q<http://www.w3.org/2000/xmlns/>, [$nn1, $nn2]); |
1134 |
sub DERIVATION_LIST () { |
for my $at_child (@{$at->child_nodes}) { |
1135 |
8} |
$attr->append_child ($at_child->clone_node (1)); |
1136 |
package Message::DOM::Element::ManakaiDOMDTDTypeInfo; |
} |
1137 |
our $VERSION = 20061231.0930; |
$attr->manakai_attribute_type ($at->declared_type); |
1138 |
push our @ISA, 'Message::DOM::IF::TypeInfo'; |
my $nsuri = $attr->value; |
1139 |
sub type_name ($;$) { |
## TODO: Namespace well-formedness check (NSURI), v1.1 chk |
1140 |
if (@_ == 1) {my ($self) = @_; |
$pfx_to_uri{$nn2} = $nsuri; |
1141 |
my $r = ''; |
$r->set_attribute_node_ns ($attr); |
1142 |
|
## NOTE: This method changes |specified| flag |
1143 |
{ |
$attr->specified (0); |
1144 |
|
$has_attr{q<http://www.w3.org/2000/xmlns/>}->{$nn2} = 1; |
1145 |
|
} else { |
1146 |
$r = { |
## TODO: NCName check |
1147 |
|
$gattr{$nn1}->{$nn2} = $at; |
1148 |
1 |
} |
1149 |
=> 'CDATA', |
} else { # no prefixed |
1150 |
|
my $attr; |
1151 |
2 |
if ($nn1 eq 'xmlns') { |
1152 |
=> 'ID', |
$attr = $self->create_attribute_ns |
1153 |
|
(q<http://www.w3.org/2000/xmlns/>, 'xmlns'); |
1154 |
3 |
$has_attr{q<http://www.w3.org/2000/xmlns/>}->{xmlns} = 1; |
1155 |
=> 'IDREF', |
} else { |
1156 |
|
$attr = $self->create_attribute_ns (undef, $nn1); |
1157 |
4 |
## TODO: NCName check |
1158 |
=> 'IDREFS', |
} |
1159 |
|
for my $at_child (@{$at->child_nodes}) { |
1160 |
5 |
$attr->append_child ($at_child->clone_node (1)); |
1161 |
=> 'ENTITY', |
} |
1162 |
|
$attr->manakai_attribute_type ($at->declared_type); |
1163 |
6 |
## TODO: Namespace well-formedness check (NSURI) |
1164 |
=> 'ENTITIES', |
$r->set_attribute_node_ns ($attr); |
1165 |
|
## NOTE: This method changes |specified| flag |
1166 |
7 |
$attr->specified (0); |
1167 |
=> 'NMTOKEN', |
} |
|
|
|
|
8 |
|
|
=> 'NMTOKENS', |
|
|
|
|
|
9 |
|
|
=> 'NOTATION', |
|
|
|
|
|
10 |
|
|
=> 'ENUMERATION', |
|
|
}->{$$self}; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMDTDTypeInfo', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'type_name'; |
|
|
} |
|
|
} |
|
|
sub type_namespace ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = { |
|
|
|
|
|
1 |
|
|
=> |
|
|
1 |
|
|
, |
|
|
|
|
|
2 |
|
|
=> |
|
|
1 |
|
|
, |
|
|
|
|
|
3 |
|
|
=> |
|
|
1 |
|
|
, |
|
|
|
|
|
4 |
|
|
=> |
|
|
1 |
|
|
, |
|
|
|
|
|
5 |
|
|
=> |
|
|
1 |
|
|
, |
|
|
|
|
|
6 |
|
|
=> |
|
|
1 |
|
|
, |
|
|
|
|
|
7 |
|
|
=> |
|
|
1 |
|
|
, |
|
|
|
|
|
8 |
|
|
=> |
|
|
1 |
|
|
, |
|
|
|
|
|
9 |
|
|
=> |
|
|
1 |
|
|
, |
|
|
|
|
|
10 |
|
|
=> |
|
|
1 |
|
|
, |
|
|
}->{$$self} ? |
|
|
'http://www.w3.org/TR/REC-xml' : |
|
|
undef; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Element::ManakaiDOMDTDTypeInfo', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'type_namespace'; |
|
|
} |
|
|
} |
|
|
sub is_derived_from ($$$$) { |
|
|
my ($self, $typeNamespaceArg, $typeNameArg, $derivationMethod) = @_; |
|
|
my $r = 0; |
|
|
|
|
|
|
|
|
$r} |
|
|
use overload |
|
|
bool => sub () {1}, |
|
|
'eq' => sub ($$) { |
|
|
my ($self, $t) = @_; |
|
|
my $r = 0; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
if |
|
|
(UNIVERSAL::isa ($t, |
|
|
'Message::DOM::IF::TypeInfo' |
|
|
)) { |
|
|
my $ln1 = $self-> |
|
|
type_name |
|
|
; |
|
|
my $ln2 = $t-> |
|
|
type_name |
|
|
; |
|
|
if ((defined $ln1 and defined $ln2 and $ln1 eq $ln2) or |
|
|
(not defined $ln1 or not defined $ln2)) { |
|
|
my $ns1 = $self-> |
|
|
type_namespace |
|
|
; |
|
|
my $ns2 = $t-> |
|
|
type_namespace |
|
|
; |
|
|
if ((defined $ns1 and defined $ns2 and $ns1 eq $ns2) or |
|
|
(not defined $ns1 and not defined $ns2)) { |
|
|
$r = |
|
|
1 |
|
|
; |
|
1168 |
} |
} |
1169 |
} |
} # attrdefs |
1170 |
|
for my $pfx (keys %gattr) { |
1171 |
|
my $nsuri = $pfx_to_uri{$pfx}; |
1172 |
|
unless (defined $nsuri) { |
1173 |
|
## TODO: Namespace well-formedness error |
1174 |
|
} |
1175 |
|
LN: for my $ln (keys %{$gattr{$pfx}}) { |
1176 |
|
if ($has_attr{defined $nsuri ? $nsuri : ''}->{$ln}) { |
1177 |
|
## TODO: Namespace well-formedness error |
1178 |
|
next LN; |
1179 |
|
} |
1180 |
|
## TODO: NCName check, prefix check and NSURI check |
1181 |
|
my $at = $gattr{$pfx}->{$ln}; |
1182 |
|
my $attr = $self->create_attribute_ns ($nsuri, [$pfx, $ln]); |
1183 |
|
for my $at_child (@{$at->child_nodes}) { |
1184 |
|
$attr->append_child ($at_child->clone_node (1)); |
1185 |
|
} |
1186 |
|
$attr->manakai_attribute_type ($at->declared_type); |
1187 |
|
$r->set_attribute_node_ns ($attr); |
1188 |
|
## NOTE: This method changes |specified| flag |
1189 |
|
$attr->specified (0); |
1190 |
|
$has_attr{defined $nsuri ? $nsuri : ''}->{$ln} = 1; |
1191 |
|
} # LN |
1192 |
|
} # pfx |
1193 |
|
$cfg->set_parameter |
1194 |
|
(q<http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree> => $copy_asis); |
1195 |
|
$self->strict_error_checking ($orig_strict); |
1196 |
} |
} |
1197 |
|
|
1198 |
|
return $r; |
1199 |
|
} # create_element_ns |
1200 |
|
|
1201 |
|
=head1 LICENSE |
1202 |
|
|
1203 |
} |
Copyright 2007 Wakaba <w@suika.fam.cx> |
|
|
|
|
|
|
|
;} |
|
1204 |
|
|
1205 |
; |
This program is free software; you can redistribute it and/or |
1206 |
|
modify it under the same terms as Perl itself. |
1207 |
|
|
1208 |
|
=cut |
1209 |
|
|
|
} |
|
|
$r} |
|
|
, |
|
|
fallback => 1; |
|
|
$Message::DOM::DOMFeature::ClassInfo->{q<Message::DOM::Element::ManakaiDOMDTDTypeInfo>}->{has_feature} = {'core', |
|
|
{'', |
|
|
'1', |
|
|
'3.0', |
|
|
'1'}, |
|
|
'xml', |
|
|
{'', |
|
|
'1', |
|
|
'3.0', |
|
|
'1'}, |
|
|
'xmlversion', |
|
|
{'', |
|
|
'1', |
|
|
'1.0', |
|
|
'1', |
|
|
'1.1', |
|
|
'1'}}; |
|
|
$Message::DOM::ClassPoint{q<Message::DOM::Element::ManakaiDOMDTDTypeInfo>} = 8.1; |
|
|
for ($Message::DOM::IF::Node::){} |
|
|
## License: <http://suika.fam.cx/~wakaba/archive/2004/8/18/license#Perl+MPL> |
|
1210 |
1; |
1; |
1211 |
|
## $Date$ |