130 |
package Message::DOM::Document; |
package Message::DOM::Document; |
131 |
|
|
132 |
sub create_entity_reference ($$) { |
sub create_entity_reference ($$) { |
133 |
return Message::DOM::EntityReference->____new (@_[0, 1]); |
our $CreateEntityReference_OpenEntity; |
134 |
|
## TODO: This is Multithread unsafe |
135 |
|
|
136 |
|
my $self = $_[0]; |
137 |
|
my $orig_strict = $self->strict_error_checking; |
138 |
|
if ($orig_strict) { |
139 |
|
my $xv = $self->xml_version; |
140 |
|
if (defined $xv) { |
141 |
|
if ($xv eq '1.0' and |
142 |
|
$_[1] =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) { |
143 |
|
# |
144 |
|
} elsif ($xv eq '1.1' and |
145 |
|
$_[1] =~ /\A\p{InXMLNameStartChar11}\p{InXMLNameChar11}*\z/) { |
146 |
|
# |
147 |
|
} else { |
148 |
|
report Message::DOM::DOMException |
149 |
|
-object => $self, |
150 |
|
-type => 'INVALID_CHARACTER_ERR', |
151 |
|
-subtype => 'MALFORMED_NAME_ERR'; |
152 |
|
} |
153 |
|
} |
154 |
|
} |
155 |
|
|
156 |
|
my $r = Message::DOM::EntityReference->____new ($self, $_[1]); |
157 |
|
|
158 |
|
## Expansion |
159 |
|
unless ($CreateEntityReference_OpenEntity->{$_[1]}) { |
160 |
|
local $CreateEntityReference_OpenEntity->{$_[1]} = 1; |
161 |
|
local $Error::Depth = $Error::Depth + 1; |
162 |
|
|
163 |
|
my $doctype = $self->doctype; |
164 |
|
unless ($doctype) { |
165 |
|
$r->manakai_set_read_only (1, 1); |
166 |
|
return $r; |
167 |
|
} |
168 |
|
|
169 |
|
my $ent = $doctype->get_general_entity_node ($_[1]); |
170 |
|
unless ($ent) { |
171 |
|
$r->manakai_set_read_only (1, 1); |
172 |
|
return $r; |
173 |
|
} |
174 |
|
|
175 |
|
$self->strict_error_checking (0); |
176 |
|
for my $c (@{$ent->child_nodes}) { |
177 |
|
my $clone = $c->clone_node (1); |
178 |
|
$r->append_child ($clone); |
179 |
|
} |
180 |
|
$r->manakai_expanded ($ent->has_replacement_tree); |
181 |
|
$self->strict_error_checking ($orig_strict); |
182 |
|
} |
183 |
|
$r->manakai_set_read_only (1, 1); |
184 |
|
return $r; |
185 |
} # create_entity_reference |
} # create_entity_reference |
186 |
|
|
187 |
=head1 LICENSE |
=head1 LICENSE |