File Coverage

blib/lib/XML/CompareML/DocBook.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package XML::CompareML::DocBook;
2              
3 1     1   4058 use strict;
  1         2  
  1         24  
4 1     1   5 use warnings;
  1         1  
  1         30  
5              
6             =head1 NAME
7              
8             XML::CompareML::DocBook - convert CompareML to DocBook
9              
10             =head1 SYNOPSIS
11              
12             See L.
13              
14             =cut
15              
16 1     1   379 use XML::LibXML::Common qw(:w3c);
  0            
  0            
17              
18             use base 'XML::CompareML::Base';
19              
20             sub _print_header
21             {
22             my $self = shift;
23             my $o = $self->{o};
24             print {*{$o}} <<"EOF";
25            
26            
27             "/usr/share/sgml/docbook/xml-dtd-4.1.2/docbookx.dtd"[
28             ]>
29            
30              
31             EOF
32             }
33              
34             # Do Nothing
35             sub _start_rendering
36             {
37             }
38              
39             # Do Nothing
40             sub _finish_rendering
41             {
42             }
43              
44             sub _print_footer
45             {
46             my $self = shift;
47             print {*{$self->{o}}} "\n";
48             }
49              
50             sub _render_section_start
51             {
52             my $self = shift;
53             my %args = (@_);
54              
55             my $depth = $args{depth};
56             my $id = $args{id};
57             my $title_string = $args{title_string};
58             my $expl = $args{expl};
59             my $sub_sections = $args{sub_sections};
60              
61             if ($depth)
62             {
63             $self->_out("
\n");
64             }
65              
66             $self->_out("$title_string\n");
67              
68             if ($depth == 0)
69             {
70             if (defined($self->_timestamp()))
71             {
72             $self->_out("" . $self->_timestamp() .
73             "\n");
74             }
75             }
76              
77             if ($expl)
78             {
79             $self->_out("\n" . $self->_xml_node_contents_to_string($expl) . "\n\n");
80             }
81             }
82              
83             sub _render_sys_table_start
84             {
85             my ($self,%args) = @_;
86              
87             my $title_string = $args{title_string};
88              
89             $self->_out(<<"EOF");
90             \n\n
91             Comparison - $title_string
92            
93            
94            
95            
96            
97             System
98             Description
99            
100            
101            
102             EOF
103             }
104              
105             sub _html_to_docbook
106             {
107             my $parent_node = shift;
108             my $not_first = shift;
109             my @child_nodes = $parent_node->childNodes();
110             my $ret = "";
111              
112             foreach my $node (@child_nodes)
113             {
114             if ($node->nodeType() == ELEMENT_NODE())
115             {
116             if ($node->nodeName() eq "a")
117             {
118             $ret .= "getAttribute("href") . "\">";
119             }
120             else
121             {
122             my @attrs = $node->attributes();
123             $ret .= "<" . $node->nodeName() . " " . join(" ", map { "$_=\"".$node->getAttribute($_)."\""} @attrs) . ">";
124             }
125             $ret .= _html_to_docbook($node, 1);
126              
127             if ($node->nodeName() eq "a")
128             {
129             $ret .= "";
130             }
131             else
132             {
133             $ret .= "nodeName() . ">";
134             }
135             }
136             else
137             {
138             $ret .= $node->toString();
139             }
140             }
141             # Remove leading and trailing space.
142             if (1)
143             {
144             $ret =~ s!^\s+!!mg;
145             $ret =~ s/\s+$//mg;
146             }
147             return $ret;
148             }
149              
150             sub _render_s_elem
151             {
152             my ($self, $s_elem) = @_;
153             return _html_to_docbook($s_elem);
154             }
155              
156             sub _render_sys_table_row
157             {
158             my ($self, %args) = @_;
159              
160             $self->_out("\n" . $args{name}. "\n" .
161             "\n" . $args{desc} . "\n\n\n");
162             }
163              
164             sub _render_sys_table_end
165             {
166             my $self = shift;
167             $self->_out("
\n");
168             }
169              
170             sub _render_section_end
171             {
172             my ($self, %args) = @_;
173              
174             my $depth = $args{depth};
175              
176             if ($depth)
177             {
178             $self->_out("\n");
179             }
180             }
181              
182             =head1 AUTHOR
183              
184             Shlomi Fish, L.
185              
186             =head1 SEE ALSO
187              
188             L
189              
190             =head1 COPYRIGHT AND LICENSE
191              
192             Copyright 2004, Shlomi Fish. All rights reserved.
193              
194             You can use, modify and distribute this module under the terms of the MIT X11
195             license. ( L ).
196              
197             =cut
198              
199             1;
200