SVG::XML - Handle the XML generation bits for SVG.pm
Ronan Oger, ronan@roasp.com
perl(1),L<SVG>,L<SVG::XML>,L<SVG::Element>,L<SVG::Parser>, L<SVG::Manual>
http://www.roitsystems.com/
http://www.w3c.org/Graphics/SVG/
use vars
qw($VERSION @ISA @EXPORT );
$s = '0' unless defined $s;
$s=join(', ',@
{$s}) if(ref($s) eq 'ARRAY');
$s=~s/&(?!#(x\w\w|\d+?);)/&/g;
$s=~s/([\x00-\x1f])/sprintf('&#x%02X;',chr($1))/eg;
#per suggestion from Adam Schneider
$s=~s/([\200-\377])/'&#'.ord($1).';'/ge;
return(join('; ',map { qq($_: ).$attrs{$_} } keys(%attrs)));
# Per suggestion from Adam Schneider
# return(join(' ',map { qq($_=").$attrs{$_}.q(") } keys(%attrs)));
return(join(' ',map { qq($_=").xmlescp($attrs{$_}).q(") } keys(%attrs)));
my ($name,$ns,%attrs)=@_;
my $at=' '.xmlattrib
(%attrs)||'';
return qq(<$ns$name$at />);
my ($name,$ns,%attrs)=@_;
return xmltag
($name,$ns,%attrs);
my ($name,$ns,%attrs)=@_;
my $at=' '.xmlattrib
(%attrs)||'';
return qq(<$ns$name$at>);
sub xmltagopen_ln
($$;@
) {
my ($name,$ns,%attrs)=@_;
return xmltagopen
($name,$ns,%attrs);
my ($self,$r_comment) = @_;
my $ind = $self->{-docref
}->{-elsep
}.$self->{-docref
}->{-indent
} x
$self->{-docref
}->{-level
};
return(join($ind,map { qq(<!-- $_ -->)} @
$r_comment));
my $ind = $self->{-docref
}->{-elsep
}.$self->{-docref
}->{-indent
} x
$self->{-docref
}->{-level
};
return(join($ind,map { qq(<?
$_?
>)} @
$r_pi));
*processinginstruction
=\
&xmlpi
;
sub xmltagclose_ln
($$) {
return xmltagclose
($name,$ns);
my $docroot = $self->{-docroot
} || 'svg';
$id = 'PUBLIC "'.$self->{-pubid
}.'"';
$id .= ' "'.$self->{-sysid
}.'"' if ($self->{-sysid
});
$id = 'SYSTEM "'.$self->{-sysid
}.'"';
$id = 'PUBLIC "-//W3C//DTD SVG 1.0//EN"' .
$self->{-docref
}->{-elsep
}.
"\"$self->{-docref}->{-dtd}\""
my $at=join(' ',($docroot, $id));
#>>>TBD: add internal() method to return this
my $extension = (exists $self->{-internal
})?
$self->{-internal
}->render():"";
if (exists $self->{-extension
} and $self->{-extension
}) {
$extension .= $self->{-docref
}{-elsep
}.
$self->{-docref
}{-elsep
};
$extension = " [".$self->{-docref
}{-elsep
}.$extension."]" if $extension;
return qq[<!DOCTYPE
$at$extension>];
my $version= $self->{-version
} || '1.0';
my $encoding = $self->{-encoding
} || 'UTF-8';
my $standalone = $self->{-standalone
} ||'yes';
return qq§
<?xml version
="$version" encoding
="$encoding" standalone
="$standalone"?
>§
.$self->{-docref
}{-elsep
};
#-------------------------------------------------------------------------------