XML-Axk
view release on metacpan or search on metacpan
lib/XML/Axk/SAX/BuildDOM2.pm view on Meta::CPAN
my $i = 0;
my $n = scalar keys %$attr;
return unless $n;
if (exists $hash->{AttributeOrder})
{
my $defaulted = $hash->{Defaulted};
my @order = @{ $hash->{AttributeOrder} };
# Specified attributes
for (my $i = 0; $i < $defaulted; $i++)
{
my $a = $order[$i];
my $att = $doc->createAttribute ($attr->{$a}->{LocalName},
$attr->{$a}->{Value}, 1);
$node->setAttributeNode ($att);
}
# Defaulted attributes
for (my $i = $defaulted; $i < @order; $i++)
{
my $a = $order[$i];
die "Defaulted attributes not supported!";
# Because I don't know what to do with them.
my $att = $doc->createAttribute ($elem, $attr->{$a}->{LocalName}, 0);
$node->setAttributeNode ($att);
}
}
else
{
# We're assuming that all attributes were specified (1)
for my $a (keys %$attr)
{
my $att = $doc->createAttribute ($attr->{$a}->{LocalName},
$attr->{$a}->{Value}, 1);
$node->setAttributeNode ($att);
}
}
} #start_element()
sub end_element
{
my $self = shift;
$self->{Element} = $self->{Element}->getParentNode;
undef $self->{LastText};
# Check for end of root element
$self->{EndDoc} = 1 if ($self->{Element} == $self->{Document});
} #end_element
sub entity_reference # was Default
{
my $self = $_[0];
my $name = $_[1]->{Name};
$self->{Element}->appendChild (
$self->{Document}->createEntityReference ($name));
undef $self->{LastText};
} #entity_reference()
sub start_cdata
{
my $self = shift;
$self->{InCDATA} = 1;
} #start_cdata()
sub end_cdata
{
my $self = shift;
$self->{InCDATA} = 0;
} #end_cdata()
sub comment
{
my $self = $_[0];
local $XML::DOM::IgnoreReadOnly = 1;
undef $self->{LastText};
my $comment = $self->{Document}->createComment ($_[1]->{Data});
$self->{Element}->appendChild ($comment);
} #comment()
sub doctype_decl
{
my ($self, $hash) = @_;
$self->{DocType}->setParams ($hash->{Name}, $hash->{SystemId},
$hash->{PublicId}, $hash->{Internal});
$self->{SawDocType} = 1;
} #doctype_decl()
sub attlist_decl
{
my ($self, $hash) = @_;
local $XML::DOM::IgnoreReadOnly = 1;
$self->{DocType}->addAttDef ($hash->{ElementName},
$hash->{AttributeName},
$hash->{Type},
$hash->{Default},
$hash->{Fixed});
} #attlist_decl()
sub xml_decl
{
my ($self, $hash) = @_;
local $XML::DOM::IgnoreReadOnly = 1;
undef $self->{LastText};
$self->{Document}->setXMLDecl (new XML::DOM::XMLDecl ($self->{Document},
$hash->{Version},
$hash->{Encoding},
$hash->{Standalone}));
} #xml_decl()
sub entity_decl
{
my ($self, $hash) = @_;
local $XML::DOM::IgnoreReadOnly = 1;
# Parameter Entities names are passed starting with '%'
my $parameter = 0;
#?? parameter entities currently not supported by PerlSAX!
undef $self->{LastText};
$self->{DocType}->addEntity ($parameter, $hash->{Name}, $hash->{Value},
( run in 0.520 second using v1.01-cache-2.11-cpan-d8267643d1d )