| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XML::NewsML_G2::Role::Writer_2_9; |
|
2
|
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
5899
|
use Moose::Role; |
|
|
6
|
|
|
|
|
16
|
|
|
|
6
|
|
|
|
|
53
|
|
|
4
|
6
|
|
|
6
|
|
32517
|
use namespace::autoclean; |
|
|
6
|
|
|
|
|
17
|
|
|
|
6
|
|
|
|
|
44
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has 'schema_location', |
|
7
|
|
|
|
|
|
|
isa => 'Str', |
|
8
|
|
|
|
|
|
|
is => 'ro', |
|
9
|
|
|
|
|
|
|
default => |
|
10
|
|
|
|
|
|
|
'http://iptc.org/std/nar/2006-10-01/ http://www.iptc.org/std/NewsML-G2/2.9/specification/NewsML-G2_2.9-spec-All-Power.xsd'; |
|
11
|
|
|
|
|
|
|
has 'g2_catalog_url', |
|
12
|
|
|
|
|
|
|
isa => 'Str', |
|
13
|
|
|
|
|
|
|
is => 'ro', |
|
14
|
|
|
|
|
|
|
default => |
|
15
|
|
|
|
|
|
|
'http://www.iptc.org/std/catalog/catalog.IPTC-G2-Standards_18.xml'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
override '_create_rights_info' => sub { |
|
18
|
|
|
|
|
|
|
my ( $self, $root ) = @_; |
|
19
|
|
|
|
|
|
|
return unless $self->news_item->copyright_holder; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $ri = $self->create_element('rightsInfo'); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$ri->appendChild( |
|
24
|
|
|
|
|
|
|
my $crh = $self->create_element( |
|
25
|
|
|
|
|
|
|
'copyrightHolder', |
|
26
|
|
|
|
|
|
|
_name_text => $self->news_item->copyright_holder |
|
27
|
|
|
|
|
|
|
) |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
if ( my $qcode = $self->news_item->copyright_holder->qcode ) { |
|
30
|
|
|
|
|
|
|
$self->scheme_manager->add_qcode_or_literal( $crh, |
|
31
|
|
|
|
|
|
|
'copyright_holder', $qcode ); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $notice = $self->news_item->copyright_holder->notice; |
|
35
|
|
|
|
|
|
|
$ri->appendChild( |
|
36
|
|
|
|
|
|
|
$self->create_element( 'copyrightNotice', _text => $notice ) ) |
|
37
|
|
|
|
|
|
|
if $notice; |
|
38
|
|
|
|
|
|
|
$ri->appendChild( |
|
39
|
|
|
|
|
|
|
$self->create_element( |
|
40
|
|
|
|
|
|
|
'usageTerms', _text => $self->news_item->usage_terms |
|
41
|
|
|
|
|
|
|
) |
|
42
|
|
|
|
|
|
|
) if $self->news_item->usage_terms; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$root->appendChild($ri); |
|
45
|
|
|
|
|
|
|
return; |
|
46
|
|
|
|
|
|
|
}; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
override '_create_catalogs' => sub { |
|
49
|
|
|
|
|
|
|
my ( $self, $root ) = @_; |
|
50
|
|
|
|
|
|
|
$root->appendChild( |
|
51
|
|
|
|
|
|
|
$self->create_element( 'catalogRef', href => $self->g2_catalog_url ) |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $cat; |
|
55
|
|
|
|
|
|
|
foreach my $scheme ( $self->scheme_manager->get_all_schemes() ) { |
|
56
|
|
|
|
|
|
|
if ( $scheme->uri ) { |
|
57
|
|
|
|
|
|
|
$root->appendChild( $cat = $self->create_element('catalog') ) |
|
58
|
|
|
|
|
|
|
unless $cat; |
|
59
|
|
|
|
|
|
|
$cat->appendChild( |
|
60
|
|
|
|
|
|
|
$self->create_element( |
|
61
|
|
|
|
|
|
|
'scheme', |
|
62
|
|
|
|
|
|
|
alias => $scheme->alias, |
|
63
|
|
|
|
|
|
|
uri => $scheme->uri |
|
64
|
|
|
|
|
|
|
) |
|
65
|
|
|
|
|
|
|
); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
return; |
|
69
|
|
|
|
|
|
|
}; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
override '_create_hierarchy' => sub { |
|
72
|
|
|
|
|
|
|
my ( $self, $node, $schema ) = @_; |
|
73
|
|
|
|
|
|
|
my @res; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
do { |
|
76
|
|
|
|
|
|
|
unshift @res, |
|
77
|
|
|
|
|
|
|
$self->scheme_manager->build_qcode( $schema, $node->qcode() ); |
|
78
|
|
|
|
|
|
|
} while ( $node = $node->parent() ); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
return $self->create_element( 'hierarchyInfo', _text => join ' ', @res ); |
|
81
|
|
|
|
|
|
|
}; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
override '_create_infosources' => sub { |
|
84
|
|
|
|
|
|
|
my ( $self, $root ) = @_; |
|
85
|
|
|
|
|
|
|
foreach ( @{ $self->news_item->sources } ) { |
|
86
|
|
|
|
|
|
|
next if $_ eq uc $self->news_item->provider->qcode; |
|
87
|
|
|
|
|
|
|
$root->appendChild( my $i = |
|
88
|
|
|
|
|
|
|
$self->create_element( 'infoSource', literal => $_ ) ); |
|
89
|
|
|
|
|
|
|
$self->scheme_manager->add_role( $i, 'isrol', 'originfo' ); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
return; |
|
92
|
|
|
|
|
|
|
}; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
override '_create_company_data' => sub { |
|
95
|
|
|
|
|
|
|
my ( $self, $org, $root ) = @_; |
|
96
|
|
|
|
|
|
|
return unless ( $self->scheme_manager->crel ); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my $crel_alias = $self->scheme_manager->crel->alias; |
|
99
|
|
|
|
|
|
|
$root->appendChild( |
|
100
|
|
|
|
|
|
|
$self->create_element( |
|
101
|
|
|
|
|
|
|
'related', |
|
102
|
|
|
|
|
|
|
rel => "$crel_alias:index", |
|
103
|
|
|
|
|
|
|
literal => $_ |
|
104
|
|
|
|
|
|
|
) |
|
105
|
|
|
|
|
|
|
) foreach ( @{ $org->indices } ); |
|
106
|
|
|
|
|
|
|
$root->appendChild( |
|
107
|
|
|
|
|
|
|
$self->create_element( |
|
108
|
|
|
|
|
|
|
'related', |
|
109
|
|
|
|
|
|
|
rel => "$crel_alias:exchange", |
|
110
|
|
|
|
|
|
|
literal => $_ |
|
111
|
|
|
|
|
|
|
) |
|
112
|
|
|
|
|
|
|
) foreach ( @{ $org->stock_exchanges } ); |
|
113
|
|
|
|
|
|
|
}; |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
override '_create_creator' => sub { |
|
116
|
|
|
|
|
|
|
my ( $self, $creator ) = @_; |
|
117
|
|
|
|
|
|
|
return $self->create_element( 'creator', literal => $creator->name ); |
|
118
|
|
|
|
|
|
|
}; |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
override '_create_teaser' => sub { }; |
|
121
|
|
|
|
|
|
|
override '_create_copyright_holder_remoteinfo' => sub { }; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
## no critic (ControlStructures::ProhibitYadaOperator Subroutines::RequireFinalReturn) |
|
124
|
1
|
|
|
1
|
|
10
|
sub _create_subjects_concepts {...} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
|
127
|
|
|
|
|
|
|
__END__ |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 NAME |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
XML::NewsML_G2::Role::Writer_2_9 - create XML DOM tree conforming to version |
|
132
|
|
|
|
|
|
|
2.9 of the NewsML-G2 specification |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Check the documentation of L<XML::NewsML_G2::Writer> for general |
|
135
|
|
|
|
|
|
|
information on this class. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 AUTHOR |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Philipp Gortan C<< <philipp.gortan@apa.at> >> |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 LICENCE AND COPYRIGHT |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Copyright (c) 2013-2014, APA-IT. All rights reserved. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
See L<XML::NewsML_G2> for the license. |