Anonymous avatar Anonymous committed 39bdc03

Implemented part of the <url> and <fullname> functionality in the
<impl> entry.

Comments (0)

Files changed (6)

 Build.PL
 Changes
+lib/XML/CompareML/Base.pm
+lib/XML/CompareML/DocBook.pm
+lib/XML/CompareML/DTD/Generate.pm
+lib/XML/CompareML/HTML.pm
+lib/XML/CompareML.pm
 MANIFEST
 META.yml # Will be created by "make dist"
 README
-lib/XML/CompareML.pm
-lib/XML/CompareML/Base.pm
-lib/XML/CompareML/DocBook.pm
-lib/XML/CompareML/HTML.pm
-lib/XML/CompareML/DTD/Generate.pm
 t/00-load.t
 t/01generate.t
+t/02sys-list.t
+t/files/scm-comparison.xml
+t/files/scm-sys-list-1.xml
 t/pod.t
-t/files/scm-comparison.xml

lib/XML/CompareML/Base.pm

     return $ret;
 }
 
+sub _impl_get_tag_text
+{
+    my $self = shift;
+    my $impl_elem = shift;
+    my $tag = shift;
+    my ($name_elem) = $impl_elem->getChildrenByTagName($tag);
+    if (!defined($name_elem))
+    {
+        return;
+    }
+    return $self->xml_node_contents_to_string($name_elem);    
+}
+
 sub _impl_get_name
 {
     my $self = shift;
     my $impl_elem = shift;
-    my ($name_elem) = $impl_elem->getChildrenByTagName("name");
-    return $self->xml_node_contents_to_string($name_elem);
+    return $self->_impl_get_tag_text($impl_elem, "name");
 }
 
 sub get_implementations

lib/XML/CompareML/DTD/Generate.pm

 <!ELEMENT comparison (meta,contents)>
 <!ELEMENT meta (implementations,timestamp?)>
 <!ELEMENT implementations (impl+)>
-<!ELEMENT impl (name)>
+<!ELEMENT impl (name,url?,fullname?,vendor?)>
 <!ELEMENT name (#PCDATA)>
+<!ELEMENT url (#PCDATA)>
+<!ELEMENT fullname (#PCDATA)>
+<!ELEMENT vendor (#PCDATA)>
 <!ELEMENT contents (section)>
 <!ELEMENT section (title,expl?,compare?,section*)>
 <!ELEMENT title (#PCDATA)>

lib/XML/CompareML/HTML.pm

 
 use strict;
 use warnings;
+use CGI ();
 
 use base 'XML::CompareML::Base';
 
     }
     $self->toc_out("</li>\n");
 }
+
+sub gen_systems_list
+{
+    my ($self, %args) = @_;
+
+    my $fh = $args{output_handle};
+
+    my @implementations = $self->findnodes("/comparison/meta/implementations/impl");
+
+    foreach my $impl (@implementations)
+    {
+        my $name = $self->_impl_get_tag_text($impl, "name");
+        my $url = $self->_impl_get_tag_text($impl, "url");
+        my $fullname = $self->_impl_get_tag_text($impl, "fullname");
+        if (!defined($url))
+        {
+            die "URL not specified for implementation " . $self->_impl_get_name($_);
+        }
+        print {$fh} qq{<li><a href="} . CGI::escapeHTML($url) . qq{">} . 
+            CGI::escapeHTML(defined($fullname) ? $fullname : $name) . qq{</a></li>\n};
+    }
+}
 1;
+#!/usr/bin/perl -w
+
+use Test::More tests => 1;
+
+use strict;
+
+use XML::CompareML::HTML;
+use IO::Scalar;
+
+my $no_use_buffer = "";
+my $file = IO::Scalar->new(\$no_use_buffer);
+my $converter = 
+    XML::CompareML::HTML->new(
+        'input_filename' => "t/files/scm-sys-list-1.xml",
+        'output_handle' => $file,
+    );
+
+my $buffer = "";
+my $fh = IO::Scalar->new(\$buffer);
+$converter->gen_systems_list(output_handle => $fh);
+
+# TEST
+is ($buffer, 
+    <<"EOF",
+<li><a href="http://www.cvshome.org/">CVS</a></li>
+<li><a href="http://subversion.tigris.org/">Subversion Version Control System</a></li>
+EOF
+    "Checking that the systems' list is correct."
+);
+

t/files/scm-sys-list-1.xml

+<?xml version='1.0' encoding='utf-8'?>
+<?xml-stylesheet type="text/xml" href="compare-ml.xsl"?>
+<!DOCTYPE comparison SYSTEM "comparison.dtd">
+<!--
+TODO:
+
+* Add intelligent merging of renamed paths.
+* Add IDE integration.
+* Add Speed (?)
+-->
+<comparison>
+    <meta>
+        <implementations>
+            <impl id="cvs">
+                <name>CVS</name>
+                <url>http://www.cvshome.org/</url>
+            </impl>
+            <impl id="svn">
+                <name>SVN</name>
+                <url>http://subversion.tigris.org/</url>
+                <fullname>Subversion Version Control System</fullname>
+            </impl>
+            
+        </implementations>
+        <timestamp>
+            $Id: scm-comparison.xml 61 2005-04-06 17:09:28Z shlomif $
+        </timestamp>
+    </meta>
+    <contents>
+<section id="main">
+    <title>Version Control System Comparison</title>
+    <expl>
+        This is a comparison of version-control systems. It is split
+        into several categories and sub-categories under which the 
+        systems are checked.
+    </expl>
+    <section id="repos_operations">
+        <title>Repository Operations</title>
+        <section id="atomic_commits">
+            <title>Atomic Commits</title>
+            <expl>
+                Support for atomic commits means that if an operation on the 
+                repository is interrupted in the middle, the repository will 
+                not be left in an inconsistant state. Are the check-in 
+                operations atomic? Are the check-in operations atomic, or can 
+                interrupting an operation leave the repository in an 
+                intermediate state?
+            </expl>
+            <compare>
+                <s id="cvs">No. CVS commits are not atomic.</s>
+                <s id="arch">Yes. Commits are atomic.</s>
+                <s id="darcs">Yes. Commits are atomic.</s>
+                <s id="subversion">Commits are atomic.</s>
+                <s id="superversion">Commits are atomic.</s>
+                <s id="svk">Commits are atomic.</s>
+                <s id="aegis">Commits are atomic.</s>
+                <s id="bitkeeper">Yes (but need to verify)</s>
+                <s id="monotone">Yes.</s>
+                <s id="opencm">Yes. Commits are atomic.</s>
+                <s id="perforce">Yes. Commits are atomic.</s>
+                <s id="vesta">Yes. Commits are atomic.</s>
+                <s id="co-op">Yes. Commits are atomic.</s>
+                <s id="vss">No. VSS commits are not atomic.</s>
+                <s id="cmsynergy">Yes. Commits are atomic.</s>
+            </compare>
+        </section>
+    </section>
+</section>
+    </contents>
+</comparison>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.