view release on metacpan or search on metacpan
lib/XML/Generator/RSS10.pm view on Meta::CPAN
$self->_contents( \%p, qw( title link ) );
$self->_call_modules( \%p );
if ( defined $p{description} ) {
$self->_element_with_cdata( '', 'description', $p{description} );
$self->_newline_if_pretty;
}
$self->_end_element( '', 'item' );
$self->_newline_if_pretty;
lib/XML/Generator/RSS10.pm view on Meta::CPAN
);
$self->_newline_if_pretty;
$self->_contents( \%p, qw( title link ) );
$self->_element_with_cdata( '', 'description', $p{description} );
$self->_newline_if_pretty;
foreach my $elt ( grep { $self->{state}{$_} } qw( image textinput ) ) {
$self->_element(
'', $elt,
lib/XML/Generator/RSS10.pm view on Meta::CPAN
$self->_start_element(@_);
$self->characters( { Data => $data } ) if length $data;
$self->_end_element(@_);
}
sub _element_with_cdata {
my $self = shift;
my $data = pop;
$self->_start_element(@_);
if ( length $data ) {
$self->start_cdata;
$self->characters( { Data => $data } );
$self->end_cdata;
}
$self->_end_element(@_);
}
sub _start_element {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
Attributes => {"{}about" => {Name => "rdf:about",
Value => $self->base()}}});
#
$self->_pcdata({Name => "vCard:CLASS",
Value => ($vcard->class() || "PUBLIC")});
foreach my $prop ("uid", "rev", "prodid") {
if (my $value = $vcard->$prop()) {
$self->_pcdata({Name => sprintf("vCard:%s",uc($prop)),
Value => $value});
}
}
#
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
sub _render_fn {
my $self = shift;
my $vcard = shift;
$self->_pcdata({Name => "vCard:FN",
Value => $vcard->fn()});
return 1;
}
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
$self->start_element({Name => "vCard:N",
Attributes => {"{}parseType"=>{Name => "rdf:parseType",
Value => "Resource"}},});
if (my $f = $n->family()) {
$self->_pcdata({Name => "vCard:Family",
Value => $n->family()});
}
if (my $g = $n->given()) {
$self->_pcdata({Name => "vCard:Given",
Value => $n->given()});
}
if (my $o = $n->middle()) {
$self->_pcdata({Name => "vCard:Other",
Value => $o});
}
if (my $p = $n->prefixes()) {
$self->_pcdata({Name => "vCard:Prefix",
Value => $p});
}
if (my $s = $n->suffixes()) {
$self->_pcdata({Name => "vCard:Suffix",
Value => $s});
}
$self->end_element({Name => "vCard:N"});
}
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
sub _render_nickname {
my $self = shift;
my $vcard = shift;
if (my $nick = $vcard->nickname()) {
$self->_pcdata({Name => "vCard:NICKNAME",
Value => $nick});
}
return 1;
}
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
sub _render_bday {
my $self = shift;
my $vcard = shift;
if (my $bday = $vcard->bday()) {
$self->_pcdata({Name => "vCard:BDAY",
Value => $bday});
}
return 1;
}
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
sub {
my $self = shift;
my $adr = shift;
if (my $p = $adr->po_box()) {
$self->_pcdata({Name => "vCard:pobox",
Value => $p});
}
if (my $e = $adr->extended()) {
$self->_pcdata({Name => "vCard:extadr",
Value => $e});
}
if (my $s = $adr->street()) {
$self->_pcdata({Name => "vCard:Street",
Value => $s});
}
if (my $c = $adr->city()) {
$self->_pcdata({Name => "vCard:Locality",
Value => $c});
}
if (my $r = $adr->region()) {
$self->_pcdata({Name => "vCard:Region",
Value => $r});
}
if (my $p = $adr->post_code()) {
$self->_pcdata({Name => "vCard:Pcode",
Value => $p});
}
if (my $c = $adr->country()) {
$self->_pcdata({Name => "vCard:Country",
Value => $c});
}
});
return 1;
}
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
$labels,
sub {
my $self = shift;
my $label = shift;
$self->_pcdata({Name => "rdf:value",
Value => $label->value(),
Attributes => {$self->_parsetype("Literal")},
CDATA => 1,});
});
return 1;
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
$tels,
sub {
my $self = shift;
my $tel = shift;
$self->_pcdata({Name => "rdf:value",
Value => $tel->value()});
});
return 1;
}
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
$addresses,
sub {
my $self = shift;
my $email = shift;
$self->_pcdata({Name => "rdf:value",
Value => $email->value()});
});
# Keep track of email addresses for
# dumping by '_render_foaf_mboxes'
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
$accounts,
sub {
my $self = shift;
my $im = shift;
$self->_pcdata({Name => "rdf:value",
Value => $im->value()});
});
return 1;
}
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
sub _render_mailer {
my $self = shift;
my $vcard = shift;
if (my $m = $vcard->mailer()) {
$self->_pcdata({Name => "vCard:MAILER",
Value => $m});
}
return 1;
}
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
sub _render_tz {
my $self = shift;
my $vcard = shift;
if (my $tz = $vcard->tz()) {
$self->_pcdata({Name => "vCard:TZ",
Value => $tz});
}
return 1;
}
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
$self->start_element({Name => "vCard:GEO",
Attributes => {"{}parseType"=>{Name => "rdf:parseType",
Value => "Resource"}},});
$self->_pcdata({Name => "geo:lat",
Value => $geo->lat()});
$self->_pcdata({Name => "geo:lon",
Value => $geo->long()});
$self->end_element({Name=>"vCard:GEO"});
return 1;
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
$self->start_element({Name => "vCard:ORG",
Attributes => \%parsetype});
if (my $n = $org->name()) {
$self->_pcdata({Name => "vCard:Orgnam",
Value => $n});
}
if (my $u = $org->unit()) {
my @units = grep { /\w/ } @$u;
my $count = scalar(@units);
if ($count == 1) {
$self->_pcdata({Name => "vCard:Orgunit",
Value => $units[0]});
}
elsif ($count) {
$self->start_element({Name => "vCard:Orgunit"});
$self->start_element({Name => "rdf:Seq"});
map {
$self->_pcdata({Name => "rdf:li",
Value => $_});
} @units;
$self->end_element({Name => "rdf:Seq"});
$self->end_element({Name => "vCard:Orgunit"});
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
sub _render_title {
my $self = shift;
my $vcard = shift;
if (my $t = $vcard->title()) {
$self->_pcdata({Name => "vCard:TITLE",
Value => $t});
}
return 1;
}
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
sub _render_role {
my $self = shift;
my $vcard = shift;
if (my $r = $vcard->role()) {
$self->_pcdata({Name => "vCard:ROLE",
Value => $r});
}
return 1;
}
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
$self->start_element({Name => "vCard:CATEGORIES"});
$self->start_element({Name => "rdf:Seq"});
foreach my $c (@$cats) {
$self->_pcdata({Name => "rdf:li",
Value => $c->value()});
}
$self->end_element({Name => "rdf:Seq"});
$self->end_element({Name => "vCard:CATEGORIES"});
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
if (! $notes) {
return 1;
}
$self->_pcdata({Name => "vCard:NOTE",
Attributes => {$self->_parsetype("Literal")},
CDATA => 1,
Value => $notes->[0]->value()});
return 1;
}
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
sub _render_url {
my $self = shift;
my $vcard = shift;
if (my $url = $vcard->url()) {
$self->_pcdata({Name => "vCard:URL",
Attributes => {"{}resource" => {Name => "rdf:resource",
Value => $url}}});
}
return 1;
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
"msn" => "foaf:msnChatID",
"jabber" => "foaf:JabberID",
"icq" => "foaf:icqChatID"};
}
sub _pcdata {
my $self = shift;
my $data = shift;
$self->start_element($data);
if ($data->{CDATA}) {
$self->start_cdata();
}
if ($data->{Value}) {
$self->characters({Data => encode_utf8($data->{Value})});
}
if ($data->{CDATA}) {
$self->end_cdata();
}
$self->end_element($data);
return 1;
}
lib/XML/Generator/vCard/RDF.pm view on Meta::CPAN
sub _mediaref {
my $self = shift;
my $el = shift;
my $obj = shift;
$self->_pcdata({Name => $el,
Attributes => {"{}resource" => {Name => "rdf:resource",
Value => $obj->value()}}});
}
sub _mediaobj {
my $self = shift;
my $obj = shift;
$self->_types($obj->types());
$self->_pcdata({Name => "vCard:ENCODING",
Value => "b"});
$self->_pcdata({Name => "rdf:value",
Attributes => {$self->_parsetype("Literal")},
Value => encode_base64($obj->value()),
CDATA => 1});
return 1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/Generator/vCard.pm view on Meta::CPAN
sub _render_fn {
my $self = shift;
my $vcard = shift;
$self->_pcdata({Name => "vCard:fn",
Value => $vcard->fn()});
return 1;
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
if (($n->family()) || ($n->given())) {
$self->start_element({Name=>"vCard:n"});
$self->_pcdata({Name => "vCard:family",
Value => $n->family()});
$self->_pcdata({Name => "vCard:given",
Value => $n->given()});
if (my $o = $n->middle()) {
$self->_pcdata({Name => "vCard:other",
Value => $o});
}
if (my $p = $n->prefixes()) {
$self->_pcdata({Name => "vCard:prefix",
Value => $p});
}
if (my $s = $n->suffixes()) {
$self->_pcdata({Name => "vCard:suffix",
Value => $s});
}
$self->end_element({Name => "vCard:n"});
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
sub _render_nickname {
my $self = shift;
my $vcard = shift;
if (my $nick = $vcard->nickname()) {
$self->_pcdata({Name => "vCard:nickname",
Value => $nick});
}
return 1;
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
sub _render_bday {
my $self = shift;
my $vcard = shift;
if (my $bday = $vcard->bday()) {
$self->_pcdata({Name => "vCard:bday",
Value => $bday});
}
return 1;
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
Attributes => {"{}del.type" => {Name => "vCard:del.type",
Value => $types}}
});
if (my $p = $adr->po_box()) {
$self->_pcdata({Name => "vCard:pobox",
Value => $p});
}
if (my $e = $adr->extended()) {
$self->_pcdata({Name => "vCard:extadr",
Value => $e});
}
if (my $s = $adr->street()) {
$self->_pcdata({Name => "vCard:street",
Value => $s});
}
if (my $c = $adr->city()) {
$self->_pcdata({Name => "vCard:locality",
Value => $c});
}
if (my $r = $adr->region()) {
$self->_pcdata({Name => "vCard:region",
Value => $r});
}
if (my $p = $adr->post_code()) {
$self->_pcdata({Name => "vCard:pcode",
Value => $p});
}
if (my $c = $adr->country()) {
$self->_pcdata({Name => "vCard:country",
Value => $c});
}
$self->end_element({Name=>"vCard:adr"});
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
foreach my $l (@$labels) {
my $types = join(";",$l->types());
$self->_pcdata({Name => "vCard:label",
Value => $l->value(),
Attributes => {"{}del.type" => {Name => "vCard:del.type",
Value => $types}}
});
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
foreach my $tel (@$numbers) {
my $types = join(";",$tel->types());
$self->_pcdata({Name => "vCard:tel",
Value => $tel->value(),
Attributes => {"{}tel.type" => {Name => "vCard:tel.type",
Value => $types}}
});
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
foreach my $e (@$addresses) {
my $types = join(";",$e->types());
$self->_pcdata({Name => "vCard:email",
Value => $e->value(),
Attributes => {"{}email.type" => {Name => "vCard:email.type",
Value => $types}}
});
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
foreach my $im (@$addresses) {
my $types = join(";",$im->types());
$self->_pcdata({Name => $im_list->{$service},
Value => $im->value(),
Attributes => {"{}im.type"=> {Name => "vCard:im.type",
Value => $types}}
});
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
my $self = shift;
my $vcard = shift;
if (my $m = $vcard->mailer()) {
$self->_pcdata({Name => "vCard:mailer",
Value => $m});
}
return 1;
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
my $self = shift;
my $vcard = shift;
if (my $tz = $vcard->tz()) {
$self->_pcdata({Name => "vCard:tz",
Value => $tz});
}
return 1;
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
#
$self->start_element({Name => "vCard:geo"});
$self->_pcdata({Name => "vCard:lat",
Value => $geo->lat()});
$self->_pcdata({Name => "vCard:lon",
Value => $geo->long()});
$self->end_element({Name => "vCard:geo"});
return 1;
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
foreach my $o (@$orgs) {
$self->start_element({Name => "vCard:org"});
if (my $name = $o->name()) {
$self->_pcdata({Name => "vCard:orgnam",
Value => $name});
}
if (my $units = $o->unit()) {
foreach my $u (grep { /\w/ } @$units) {
$self->_pcdata({Name => "vCard:orgunit",
Value => $u});
}
}
$self->end_element({Name => "vCard:org"});
lib/XML/Generator/vCard.pm view on Meta::CPAN
my $self = shift;
my $vcard = shift;
if (my $t = $vcard->title()) {
$self->_pcdata({Name => "vCard:title",
Value => $t});
}
return 1;
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
my $self = shift;
my $vcard = shift;
if (my $r = $vcard->role()) {
$self->_pcdata({Name => "vCard:role",
Value => $r});
}
return 1;
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
$self->start_element({Name => "vCard:categories"});
foreach (split(",",$cats->[0]->value())) {
$self->_pcdata({Name => "vCard:item",
Value => $_});
}
$self->end_element({Name => "vCard:categories"});
return 1;
lib/XML/Generator/vCard.pm view on Meta::CPAN
if (! $n) {
return 1;
}
if (my $n = $vcard->note()) {
$self->_pcdata({Name => "vCard:note",
CDATA => 1,
Value => $n});
}
return 1;
lib/XML/Generator/vCard.pm view on Meta::CPAN
sub _render_url {
my $self = shift;
my $vcard = shift;
if (my $url = $vcard->url()) {
$self->_pcdata({Name => "vCard:url",
Attributes => {"{}uri" => {Name => "vCard:uri",
Value => $url}}});
}
return 1;
lib/XML/Generator/vCard.pm view on Meta::CPAN
"msn" => "foaf:msnChatID",
"jabber" => "foaf:JabberID",
"icq" => "foaf:icqChatID"};
}
sub _pcdata {
my $self = shift;
my $data = shift;
$self->start_element($data);
if ($data->{CDATA}) {
$self->start_cdata();
}
if ($data->{Value}) {
$self->characters({Data => encode_utf8($data->{Value})});
}
if ($data->{CDATA}) {
$self->end_cdata();
}
$self->end_element($data);
return 1;
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
$self->start_element({Name => $data->{name},
Attributes => $attrs});
if ($obj->is_type("base64")) {
$self->_pcdata({Name => "vCard:b64bin",
Value => encode_base64($obj->value()),
CDATA => 1});
}
else {
$self->_pcdata({Name => "extref",
Attributes => {"{}uri" => {Name => "vCard:uri",
Value => $obj->value()}}
});
}
lib/XML/Generator/vCard.pm view on Meta::CPAN
foreach my $foo (@$custom) {
my $types = join(";",$foo->types());
$self->_pcdata({Name => "foo:bar",
Value => $foo->value(),
Attributes => {"{}type"=> {Name => "type",
Value => $types}}
});
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/GenericJSON.pm view on Meta::CPAN
my @types=(0,
'element', #1
'attribute', #2
'text', #3
'cdata', #4
'entity_ref', #5
'entity_node', #6
'pi', #7
'comment', #8
'document', #9
lib/XML/GenericJSON.pm view on Meta::CPAN
my $strip_whitespace = 1;
$strip_whitespace = shift if defined $_[0];
my $perlish_node = {};
if ($xml_node->nodeType == 3) {#text - just store the scalar
return $xml_node->data;
}elsif (defined $simple_types->{$xml_node->nodeType}) {#cdata,pi,comment - store type plus data
$perlish_node->{type} = $types[$xml_node->nodeType];
$perlish_node->{data} = $xml_node->nodeValue;
return $perlish_node;
} else {#Probably an element, but it should work regardless
$perlish_node->{type} = $types[$xml_node->nodeType];
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/Grammar/Fortune/ToText.pm view on Meta::CPAN
my @text_childs = $text_node->childNodes();
if ( @text_childs != 1 )
{
Carp::confess('@cdata is not 1');
}
my $cdata = $text_childs[0];
if ( $cdata->nodeType() != XML_CDATA_SECTION_NODE() )
{
Carp::confess("Not a cdata");
}
my $value = $cdata->nodeValue();
$value =~ s{\n+\z}{}g;
$self->_out("$value\n");
return;
view all matches for this distribution
view release on metacpan or search on metacpan
extradata/xhtml-notations-1.mod view on Meta::CPAN
<!-- W3C XML 1.0 Recommendation -->
<!NOTATION w3c-xml
PUBLIC "ISO 8879//NOTATION Extensible Markup Language (XML) 1.0//EN" >
<!-- XML 1.0 CDATA -->
<!NOTATION cdata
PUBLIC "-//W3C//NOTATION XML 1.0: CDATA//EN" >
<!-- SGML Formal Public Identifiers -->
<!NOTATION fpi
PUBLIC "ISO 8879:1986//NOTATION Formal Public Identifier//EN" >
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/Grove.pm view on Meta::CPAN
$type_name = 'characters';
package XML::Grove::CData;
use vars qw{ @ISA $type_name };
@ISA = qw{XML::Grove};
$type_name = 'cdata';
package XML::Grove::ElementDecl;
use vars qw{ @ISA $type_name };
@ISA = qw{XML::Grove};
$type_name = 'element_decl';
view all matches for this distribution
view release on metacpan or search on metacpan
Composer.pm view on Meta::CPAN
$self->print (&$esc ($event->{Data}));
}
}
sub start_cdata
{
my $self = shift;
$self->{InCDATA} = 1;
$self->print ("<![CDATA[");
}
sub end_cdata
{
my $self = shift;
$self->{InCDATA} = 0;
$self->print ("]]>");
view all matches for this distribution
view release on metacpan or search on metacpan
sub end_element {}
sub characters {}
sub processing_instruction {}
sub ignorable_whitespace {}
sub comment {}
sub start_cdata {}
sub end_cdata {}
sub start_entity {}
sub end_entity {}
sub xml_decl {}
sub start_dtd {
view all matches for this distribution
view release on metacpan or search on metacpan
dtd2html.pl view on Meta::CPAN
sub end_element {}
sub characters {}
sub processing_instruction {}
sub ignorable_whitespace {}
sub comment {}
sub start_cdata {}
sub end_cdata {}
sub start_entity {}
sub end_entity {}
sub xml_decl {}
sub start_dtd {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/Handler/ExtOn.pm view on Meta::CPAN
=item * on_end_element
=item * on_characters
=item * on_cdata
=back
XML::Handler::ExtOn put all B<cdata> characters into a single event C<on_cdata>.
It compliant XML namespaces (http://www.w3.org/TR/REC-xml-names/), by support
I<default namespace> and I<namespace scoping>.
XML::Handler::ExtOn provide methods for create XML, such as C<mk_element>, C<mk_cdata> ...
=head1 FUNCTIONS
=cut
lib/XML/Handler/ExtOn.pm view on Meta::CPAN
use base 'XML::SAX::Base';
use vars qw( $AUTOLOAD);
$XML::Handler::ExtOn::VERSION = '0.06';
### install get/set accessors for this object.
for my $key (qw/ context _objects_stack _cdata_mode _cdata_characters/) {
no strict 'refs';
*{ __PACKAGE__ . "::$key" } = sub {
my $self = shift;
$self->{___EXT_on_attrs}->{$key} = $_[0] if @_;
return $self->{___EXT_on_attrs}->{$key};
lib/XML/Handler/ExtOn.pm view on Meta::CPAN
sub new {
my $class = shift;
my $self = &XML::SAX::Base::new( $class, @_, );
$self->_objects_stack( [] );
$self->_cdata_mode(0);
my $buf;
$self->_cdata_characters( \$buf ); #setup cdata buffer
my $doc_context = new XML::Handler::ExtOn::Context::;
$self->context($doc_context);
return $self;
}
lib/XML/Handler/ExtOn.pm view on Meta::CPAN
For example:
sub on_start_element {
my $self = shift;
my $elem = shift;
$elem->add_content( $self->mk_cdata("test"));
return $elem
}
...
return [ $elem, ,$self->mk_element("after_start_elem") ]
lib/XML/Handler/ExtOn.pm view on Meta::CPAN
sub on_characters {
my ( $self, $elem, $str ) = @_;
return $str;
}
=head2 on_cdata ( $current_element, $data )
Must return string for write to stream
sub on_cdata {
my ( $self, $elem, $str ) = @_;
return lc $str;
}
=cut
sub on_cdata {
my ( $self, $elem, $str ) = @_;
return $str;
}
#set flag for cdata content
sub start_cdata {
my $self = shift;
$self->_cdata_mode(1);
return;
}
#set flag to end cdata
sub end_cdata {
my $self = shift;
if ( my $elem = $self->current_element
and defined( my $cdata_buf = ${ $self->_cdata_characters } ) )
{
if ( defined( my $data = $self->on_cdata( $elem, $cdata_buf ) ) ) {
$self->SUPER::start_cdata;
$self->SUPER::characters( { Data => $data } );
$self->SUPER::end_cdata;
}
}
#after all clear cd_data_buffer and reset cd_data mode flag
my $new_buf;
$self->_cdata_characters( \$new_buf );
$self->_cdata_mode(0);
return;
}
sub characters {
my $self = shift;
lib/XML/Handler/ExtOn.pm view on Meta::CPAN
return
# #warn "characters without element"
}
#for cdata section collect characters in buffer
if ( $self->_cdata_mode ) {
${ $self->_cdata_characters } .= $data->{Data};
return;
}
#collect chars fo current element
if (
lib/XML/Handler/ExtOn.pm view on Meta::CPAN
}
);
return $parser;
}
=head2 mk_cdata $string | \$string
return command for insert cdata to stream
=cut
sub mk_cdata {
my $self = shift;
my $string = shift;
return { type => 'CDATA', data => ref($string) ? $string : \$string };
}
lib/XML/Handler/ExtOn.pm view on Meta::CPAN
}
$self->end_element($comm);
}
elsif ( ref($comm) eq 'HASH' and exists $comm->{type} ) {
if ( $comm->{type} eq 'CDATA' ) {
$self->start_cdata;
$self->characters( { Data => ${ $comm->{data} } } );
$self->end_cdata;
}
elsif ( $comm->{type} eq 'CHARACTERS' ) {
$self->characters( { Data => ${ $comm->{data} } } );
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
YAWriter.pm view on Meta::CPAN
my ($self, $string) = @_;
return &{$self->{EscSub}}($string, $self->{'Escape'});
}
sub start_cdata {
my ($self, $cdata) = @_;
$self->{'InCDATA'} = 1;
$self->print(undef, '<![CDATA[', undef);
}
sub end_cdata {
my ($self, $cdata) = @_;
$self->{'InCDATA'} = 0;
$self->print(undef, ']]>', undef);
}
sub print {
view all matches for this distribution
view release on metacpan or search on metacpan
$XML::Hash::LX::X2H{trim} = 0; # don't trim whitespace
$XML::Hash::LX::X2H{attr} = '+'; # make attributes as keys with prefix '+';
$XML::Hash::LX::X2H{text} = '~'; # make text node as key '~';
#$XML::Hash::LX::X2H{join} = ' '; # join all whitespaces with ' ';
#$XML::Hash::LX::X2H{join} = undef;# don't join text nodes
$XML::Hash::LX::X2H{cdata} = '#'; # separate cdata sections from common values and save it under key '#';
$XML::Hash::LX::X2H{comm} = '//'; # keep comments and store under key '//';
# array cast
$XML::Hash::LX::X2A{nest} = 1; # node with name 'nest' should be always stored as array
#$XML::Hash::LX::X2A = 1; # all nodes should be always stored as array
first
<v>a</v>
mid
<!-- something commented -->
<v at="a">b</v>
<vv><![CDATA[ cdata <<>> content ]]></vv>
last
</nest>
</root>},
attr => '.', # locally override attr to be prefixed with '.'
;
# hash to xml options
$XML::Hash::LX::H2X{trim} = 1; # ignore whitespace
$XML::Hash::LX::H2X{attr} = '+'; # keys, starting from '+' are attributes
$XML::Hash::LX::H2X{text} = '~'; # key '~' is text node
$XML::Hash::LX::H2X{cdata} = '#'; # key '#' is CDATA node
$XML::Hash::LX::H2X{comm} = '//'; # key '//' is comment node
# scalarref is treated as raw xml
$hash->{root}{inject} = \('<rawnode attr="zzz" />');
# refref is treated as XML::LibXML elements, and will be cloned and inserted
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/Hash/XS.pm view on Meta::CPAN
require XSLoader;
XSLoader::load('XML::Hash::XS', $VERSION);
use vars qw($method $output $root $version $encoding $utf8 $indent $canonical
$use_attr $content $xml_decl $doc $max_depth $attr $text $trim $cdata
$comm $buf_size $keep_root $force_array $force_content $merge_text
$suppress_empty
);
# 'NATIVE' or 'LX'
lib/XML/Hash/XS.pm view on Meta::CPAN
$suppress_empty = 0;
# XML::Hash::LX options
$attr = '-';
$text = '#text';
$cdata = undef;
$comm = undef;
1;
__END__
=head1 NAME
lib/XML/Hash/XS.pm view on Meta::CPAN
if method is 'LX' then conversion result is the same as using L<XML::Hash::LX> library
Note: for 'LX' method following additional options are available:
attr
cdata
text
comm
=back
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/LibXML/LazyBuilder.pm view on Meta::CPAN
# This is a map of all the DOM level 3 node names for
# non-element/attribute nodes. Note how there is no provision for
# processing instructions.
my %NODES = (
'#cdata-section' => 1,
'#comment' => 1,
'#document' => 1,
'#document-fragment' => 1,
'#text' => 1,
);
view all matches for this distribution
view release on metacpan or search on metacpan
doap.ttl
t/01basic.t
t/02stripws.t
t/03indent.t
t/04print.t
t/61cdata.t
Copyright: Copyright 2014 Toby Inkster.
License: GPL-1.0+ or Artistic-1.0
Files: CONTRIBUTING
INSTALL
view all matches for this distribution
view release on metacpan or search on metacpan
t/10XMLin.t view on Meta::CPAN
is_deeply($opt, $target, 'keeproot option works');
# confirm that CDATA sections parse correctly
$xml = q{<opt><cdata><![CDATA[<greeting>Hello, world!</greeting>]]></cdata></opt>};
$opt = XMLin($xml, @cont_key);
is_deeply($opt, {
'cdata' => '<greeting>Hello, world!</greeting>'
}, 'CDATA section parsed correctly');
$xml = q{<opt><x><![CDATA[<y>one</y>]]><![CDATA[<y>two</y>]]></x></opt>};
$opt = XMLin($xml, @cont_key);
is_deeply($opt, {
view all matches for this distribution
view release on metacpan or search on metacpan
no_blanks => XML_PARSE_NOBLANKS,
expand_xinclude => XML_PARSE_XINCLUDE,
xinclude => XML_PARSE_XINCLUDE,
no_network => XML_PARSE_NONET,
clean_namespaces => XML_PARSE_NSCLEAN,
no_cdata => XML_PARSE_NOCDATA,
no_xinclude_nodes => XML_PARSE_NOXINCNODE,
old10 => XML_PARSE_OLD10,
no_base_fix => XML_PARSE_NOBASEFIX,
huge => XML_PARSE_HUGE,
oldsax => XML_PARSE_OLDSAX,
}
$flags |= 64 if $opts->{suppress_warnings};
$flags |= 128 if exists $opts->{pedantic_parser} ? $opts->{pedantic_parser} : $self->pedantic_parser;
$flags |= 256 if exists $opts->{no_blanks} ? $opts->{no_blanks} : !$self->keep_blanks;
$flags |= 2048 if exists $opts->{no_network} ? $opts->{no_network} : !$self->no_network;
$flags |= 16384 if $opts->{no_cdata};
$flags |= 65536 if $opts->{compact}; # compact small text nodes; no modification
# of the tree allowed afterwards
# (WILL possibly CRASH IF YOU try to MODIFY THE TREE)
$flags |= 524288 if $opts->{huge}; # relax any hardcoded limit from the parser
$flags |= 1048576 if $opts->{oldsax}; # parse using SAX2 interface from before 2.7.0
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/LibXSLT.pm view on Meta::CPAN
use XML::LibXML;
my $xslt = XML::LibXSLT->new();
my $source = XML::LibXML->load_xml(location => 'foo.xml');
my $style_doc = XML::LibXML->load_xml(location=>'bar.xsl', no_cdata=>1);
my $stylesheet = $xslt->parse_stylesheet($style_doc);
my $results = $stylesheet->transform($source);
lib/XML/LibXSLT.pm view on Meta::CPAN
invalid, an exception will be thrown, so wrap the call to
parse_stylesheet in an eval{} block to trap this.
IMPORTANT: C<$stylesheet_doc> should not contain CDATA sections,
otherwise libxslt may misbehave. The best way to assure this is to
load the stylesheet with no_cdata flag, e.g.
my $stylesheet_doc = XML::LibXML->load_xml(location=>"some.xsl", no_cdata=>1);
=item parse_stylesheet_file($filename)
Exactly the same as the above, but parses the given filename directly.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/Liberal/Remedy/NestedCDATA.pm view on Meta::CPAN
my($driver, $error, $xml_ref) = @_;
return 0 if $error->message !~ /^parser error : Opening and ending tag mismatch:/;
while ($$xml_ref =~ /(?<= <!\[CDATA\[ ) (.*? \]\]> )/xmsg) {
my ($cdata, $start, $end) = ($1, $-[1], $+[1]);
next if $cdata !~ /<!\[CDATA\[/;
my $escaped = encode_entities($cdata, '<>&');
substr($$xml_ref, $start, $end - $start) = "]]>$escaped<![CDATA[";
return 1;
}
return 0;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Test/XML/Loy.pm view on Meta::CPAN
$desc
);
};
# Test for exact pcdata match
sub text_is {
my ($self, $selector, $value, $desc) = @_;
return $self->_test(
'is',
$self->_text($selector),
lib/Test/XML/Loy.pm view on Meta::CPAN
_desc($desc, qq{exact match for selector "$selector"})
);
};
# Test for pcdata mismatch
sub text_isnt {
my ($self, $selector, $value, $desc) = @_;
return $self->_test(
'isnt',
$self->_text($selector),
lib/Test/XML/Loy.pm view on Meta::CPAN
_desc($desc, qq{no match for selector "$selector"})
);
};
# Test for pcdata similarity
sub text_like {
my ($self, $selector, $regex, $desc) = @_;
return $self->_test(
'like',
$self->_text($selector),
lib/Test/XML/Loy.pm view on Meta::CPAN
_desc($desc, qq{similar match for selector "$selector"})
);
};
# Test for pcdata dissimilarity
sub text_unlike {
my ($self, $selector, $regex, $desc) = @_;
return $self->_test(
'unlike',
$self->_text($selector),
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/MinWriter.pm view on Meta::CPAN
sub startTag { my $self = shift; $self->flush_pyx; $self->SUPER::startTag(@_); }
sub emptyTag { my $self = shift; $self->flush_pyx; $self->SUPER::emptyTag(@_); }
sub endTag { my $self = shift; $self->flush_pyx; $self->SUPER::endTag(@_); }
sub characters { my $self = shift; $self->flush_pyx; $self->SUPER::characters(@_); }
sub raw { my $self = shift; $self->flush_pyx; $self->SUPER::raw(@_); }
sub cdata { my $self = shift; $self->flush_pyx; $self->SUPER::cdata(@_); }
sub dataElement { my $self = shift; $self->flush_pyx; $self->SUPER::dataElement(@_); }
sub end { my $self = shift; $self->flush_pyx; $self->SUPER::end(@_); }
sub write_pyx {
my $self = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/Mini/Document.pm view on Meta::CPAN
my $unaryName = $2;
my $unaryAttribs = $3;
my $headerName = $4;
my $headerAttribs= $5;
my $comment = $6;
my $cdata = $7;
my $doctype = $8;
my $doctypeCont = $9;
my $entityName = $10;
my $entityCont = $12;
my $plainText = $13;
lib/XML/Mini/Document.pm view on Meta::CPAN
my $newElement = XML::Mini::Element::Header->new($headerName);
$self->_extractAttributesFromString($newElement, $headerAttribs) if ($headerAttribs);
$parentElement->appendChild($newElement);
} elsif (defined $comment) {
$parentElement->comment($comment);
} elsif (defined $cdata) {
my $newElement = XML::Mini::Element::CData->new($cdata);
$parentElement->appendChild($newElement);
} elsif ($doctype || defined $doctypeCont) {
my $newElement = XML::Mini::Element::DocType->new($doctype);
$parentElement->appendChild($newElement);
if ($doctypeCont)
lib/XML/Mini/Document.pm view on Meta::CPAN
{
# Check which string matched.'
my $uname = $7;
my $comment = $6;
my $cdata = $10;
my $doctypedef = $11;
if ($12)
{
if ($doctypedef)
{
lib/XML/Mini/Document.pm view on Meta::CPAN
} elsif (defined $comment) {
#my $newElement = XML::Mini::Element::Comment->new('!--');
#$newElement->createNode($comment);
$parentElement->comment($comment);
} elsif (defined $cdata) {
my $newElement = XML::Mini::Element::CData->new($cdata);
$parentElement->appendChild($newElement);
} elsif (defined $doctypedef) {
my $newElement = XML::Mini::Element::DocType->new($11);
$parentElement->appendChild($newElement);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/Minifier.pm view on Meta::CPAN
#Â A. If we have <name> </name> we should keep it anyway (unless forced with argument)
# B. If we have </name> </person> we should *maybe* remove (in this case parent node contains more than one child node : text node + element node)
# C. If we have <person> <name> we should *maybe* remove it (in this case parent node contains more than one child node : text node + element node)
# D. If we have </person> <person> we should *maybe* remove it (in this case parent node contains more than one child node : text node + element node)
#Â B, C, D : remove... unless explicitely declared in DTD as potential #PCDATA container OR unless it contains something...
# *something* is a comment (not removed), some other text not empty, some cdata.
# Imagine </name> <!-- comment --> some text </person> then we don't want to remove spaces in the first text node
# Same with </name> <!-- comment --> </person>
# But if comments are removed then the latter piece of code will become </name></person>
my $empty = 1;
lib/XML/Minifier.pm view on Meta::CPAN
}
if($child->nodeType eq XML_COMMENT_NODE and $opt{keep_comments}) {
$empty = 0;
last;
}
if($child->nodeType eq XML_CDATA_SECTION_NODE and $opt{keep_cdata}) {
$empty = 0;
last;
}
if($child->nodeType eq XML_PI_NODE and $opt{keep_pi}) {
$empty = 0;
lib/XML/Minifier.pm view on Meta::CPAN
} elsif($child->nodeType eq XML_COMMENT_NODE) {
#Â Configurable with keep_comments
my $com = $doc->createComment($child->getData());
$opt{keep_comments} and $outnode->addChild($com);
} elsif($child->nodeType eq XML_CDATA_SECTION_NODE) {
#Â Configurable with keep_cdata
#my $cdata = $child->cloneNode(1);
my $cdata = $doc->createCDATASection($child->getData());
$opt{keep_cdata} and $outnode->addChild($cdata);
} elsif($child->nodeType eq XML_PI_NODE) {
#Â Configurable with keep_pi
#my $pi = $child->cloneNode(1);
my $pi = $doc->createPI($child->nodeName, $child->getData());
$opt{keep_pi} and $outnode->addChild($pi);
lib/XML/Minifier.pm view on Meta::CPAN
In addition, the minifier will drop every blanks between the first level children.
What you can find between first level children is not supposed to be meaningful data then we we can safely remove formatting here.
For instance we can remove a carriage return between prolog and a processing instruction (or even inside a DTD).
In addition again, the minifier will I<smartly> remove blanks between tags. By I<smart> I mean that it will not remove blanks if we are in a leaf (more chances to be meaningful blanks) or if the node contains something that will persist (a I<not remo...
If there is no DTD (very often), we are blind and simply use the approach I just described above (keep blanks in leafs, remove blanks in nodes if all siblings contains only blanks).
Everything listed above is the default and should be perceived as almost lossyless minification in term of semantic (for humans).
lib/XML/Minifier.pm view on Meta::CPAN
A comment is something like :
<!-- comment -->
=item B<keep_cdata>
Keep cdata, by default they are removed.
A CDATA is something like :
<![CDATA[ my cdata ]]>
=item B<keep_pi>
Keep processing instructions.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/Minify.pm view on Meta::CPAN
#Â A. If we have <name> </name> we should keep it anyway (unless forced with argument)
# B. If we have </name> </person> we should *maybe* remove (in this case parent node contains more than one child node : text node + element node)
# C. If we have <person> <name> we should *maybe* remove it (in this case parent node contains more than one child node : text node + element node)
# D. If we have </person> <person> we should *maybe* remove it (in this case parent node contains more than one child node : text node + element node)
#Â B, C, D : remove... unless explicitely declared in DTD as potential #PCDATA container OR unless it contains something...
# *something* is a comment (not removed), some other text not empty, some cdata.
# Imagine </name> <!-- comment --> some text </person> then we don't want to remove spaces in the first text node
# Same with </name> <!-- comment --> </person>
# But if comments are removed then the latter piece of code will become </name></person>
my $empty = 1;
lib/XML/Minify.pm view on Meta::CPAN
}
if($child->nodeType eq XML_COMMENT_NODE and $opt{keep_comments}) {
$empty = 0;
last;
}
if($child->nodeType eq XML_CDATA_SECTION_NODE and $opt{keep_cdata}) {
$empty = 0;
last;
}
if($child->nodeType eq XML_PI_NODE and $opt{keep_pi}) {
$empty = 0;
lib/XML/Minify.pm view on Meta::CPAN
} elsif($child->nodeType eq XML_COMMENT_NODE) {
#Â Configurable with keep_comments
my $com = $doc->createComment($child->getData());
$opt{keep_comments} and $outnode->addChild($com);
} elsif($child->nodeType eq XML_CDATA_SECTION_NODE) {
#Â Configurable with keep_cdata
#my $cdata = $child->cloneNode(1);
my $cdata = $doc->createCDATASection($child->getData());
$opt{keep_cdata} and $outnode->addChild($cdata);
} elsif($child->nodeType eq XML_PI_NODE) {
#Â Configurable with keep_pi
#my $pi = $child->cloneNode(1);
my $pi = $doc->createPI($child->nodeName, $child->getData());
$opt{keep_pi} and $outnode->addChild($pi);
lib/XML/Minify.pm view on Meta::CPAN
In addition, the minifier will drop every blanks between the first level children.
What you can find between first level children is not supposed to be meaningful data then we we can safely remove formatting here.
For instance we can remove a carriage return between prolog and a processing instruction (or even inside a DTD).
In addition again, the minifier will I<smartly> remove blanks between tags. By I<smart> I mean that it will not remove blanks if we are in a leaf (more chances to be meaningful blanks) or if the node contains something that will persist (a I<not remo...
If there is no DTD (very often), we are blind and simply use the approach I just described above (keep blanks in leafs, remove blanks in nodes if all siblings contains only blanks).
Everything listed above is the default and should be perceived as almost lossyless minification in term of semantic (for humans).
lib/XML/Minify.pm view on Meta::CPAN
A comment is something like :
<!-- comment -->
=item B<keep_cdata>
Keep cdata, by default they are removed.
A CDATA is something like :
<![CDATA[ my cdata ]]>
=item B<keep_pi>
Keep processing instructions.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/NewsML_G2/Inline_CData.pm view on Meta::CPAN
1;
__END__
=head1 NAME
XML::NewsML_G2::Inline_CData - inline cdata specification
=head1 SYNOPSIS
my $data = XML::NewsML_G2::Inline_CData->new
(mimetype => 'text/xml',
view all matches for this distribution
view release on metacpan or search on metacpan
ParseDTD.pm view on Meta::CPAN
for($type) {
#/^ID(REF)?$/ && do { $pdtd{'Attr'}->{$elem}->{$attr} = \&XML::ParseDTD::_check_id; last; };
/^ID(REF)?$/ && do { $pdtd{'Attr'}->{$elem}->{$attr} = ['ID', '^[A-Za-z_]{1}[A-Za-z0-9_:.-]*$']; last; };
#/^IDREFS$/ && do { $pdtd{'Attr'}->{$elem}->{$attr} = \&XML::ParseDTD::_check_idrefs; last; };
/^IDREFS$/ && do { $pdtd{'Attr'}->{$elem}->{$attr} = ['IDREFS', '^[A-Za-z_]{1}[A-Za-z0-9_:. -]*$']; last; };
#/^CDATA$/ && do { $pdtd{'Attr'}->{$elem}->{$attr} = \&XML::ParseDTD::_check_cdata; last; };
/^CDATA$/ && do { $pdtd{'Attr'}->{$elem}->{$attr} = ['CDATA', '.*']; last; };
#/^PCDATA$/ && do { $pdtd{'Attr'}->{$elem}->{$attr} = \&XML::ParseDTD::_check_pcdata; last; };
/^PCDATA$/ && do { $pdtd{'Attr'}->{$elem}->{$attr} = ['PCDATA', '.*']; last; };
#/^NMTOKEN$/ && do { $pdtd{'Attr'}->{$elem}->{$attr} = \&XML::ParseDTD::_check_nmtoken; last; };
/^NMTOKEN$/ && do { $pdtd{'Attr'}->{$elem}->{$attr} = ['NMTOKEN', '^[A-Za-z0-9_:.-]{1}\S*$']; last; };
/^\((.*)\)$/s && do {
$_ = $1;
view all matches for this distribution
view release on metacpan or search on metacpan
t/00use.t
t/01source.t
t/02maildemo.t
t/03rdf.t
t/04ppd.t
t/05cdata.t
t/basic.xml
t/cdata.xml
t/DBI.ppd
t/mail.xml
t/uploads.rdf
examples/DBI.ppd
examples/ppd.pl
view all matches for this distribution
view release on metacpan or search on metacpan
lib/XML/Parser/Lite/Tree.pm view on Meta::CPAN
$self->{__parser} = new XML::Parser::LiteCopy
Handlers => {
Start => sub { $self->_start_tag(@_); },
Char => sub { $self->_do_char(@_); },
CData => sub { $self->_do_cdata(@_); },
End => sub { $self->_end_tag(@_); },
Comment => sub { $self->_do_comment(@_); },
PI => sub { $self->_do_pi(@_); },
Doctype => sub { $self->_do_doctype(@_); },
};
lib/XML/Parser/Lite/Tree.pm view on Meta::CPAN
push @{$self->{tag_stack}->[-1]->{children}}, $new_tag;
}
1;
}
sub _do_cdata {
my $self = shift;
shift;
for my $content(@_){
my $new_tag = {
'type' => 'cdata',
'content' => $content,
};
push @{$self->{tag_stack}->[-1]->{children}}, $new_tag;
}
view all matches for this distribution
view release on metacpan or search on metacpan
survives README.md regeneration
- Rename README to README.md and regenerate from POD
Maintenance:
- PR #208 Modernize 10 legacy test files from print-ok style to
Test::More (cdata, finish, deep_nesting, xml_escape, partial,
char_end_doc, current_length, combine_chars, utf8_stream, defaulted)
2.53 2026-03-25 (by Todd Rinaldo)
Fixes:
the default handler.
- For lwp_ext_ent_handler, use URI::URL instead of URI so that old
5.004 installations will work with it.
2.25 Fri Jul 23 06:23:43 EDT 1999
- Now using Version 1990709 of expat. No local patches.
- Numerous people reported a SEGV problem when running t/cdata
on various platforms and versions of perl. The problem was
introduced with the setHandlers change. In some cases an
un-initialized value was being returned.
- Added an additional external entity handler, lwp_ext_ent_handler,
that deals with general URIs. It is installed instead of the
view all matches for this distribution