Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

documentation

  • Loading branch information...
commit e966694747235df6d87581a6892067410800f66d 1 parent cd8346e
Ruslan Zakirov authored January 26, 2011

Showing 2 changed files with 182 additions and 9 deletions. Show diff stats Hide diff stats

  1. 87  README
  2. 104  lib/Parse/ACNS.pm
87  README
@@ -3,12 +3,91 @@ NAME
3 3
 
4 4
 SYNOPSIS
5 5
         use Parse::ACNS;
6  
-        my $parser = Parse::ACNS->new(
7  
-            version => 'compat',
8  
-        );
9  
-        $parser->parse( );
  6
+        my $data = Parse::ACNS->new->parse( XML::LibXML->load_xml( string => $xml ) );
10 7
 
11 8
 DESCRIPTION
  9
+    ACNS stands for Automated Copyright Notice System. It's an open source,
  10
+    royalty free system that universities, ISP's, or anyone that handles
  11
+    large volumes of copyright notices can implement on their network to
  12
+    increase the efficiency and reduce the costs of responding to the
  13
+    notices... See "http://mpto.unistudios.com/xml/" for more details.
  14
+
  15
+    This module parses ACNS XML into a perl data structure. Supports both
  16
+    0.6 and 0.7 version. Parser strictly follows XML Schemas, so throws
  17
+    errors on malformed data.
  18
+
  19
+    However, it doesn't extract ACNS XML from email messages.
  20
+
  21
+METHODS
  22
+  new
  23
+    Constructor, takes list of named arguments.
  24
+
  25
+    version - version of the specification
  26
+
  27
+        compat - default value, can parse both 0.7 and 0.6 XML by making
  28
+        TimeStamp element in Infringement/Content/Item optional. This is the
  29
+        only difference between the spec versions.
  30
+        0.7 or 0.6 - strict parsing of the specified version.
  31
+
  32
+  parse
  33
+        my $data = Parse::ACNS->new->parse( XML::LibXML->load_xml(...) );
  34
+
  35
+    Takes XML::LibXML::Document containing an ACNS XML and returns it as a
  36
+    perl struture. Read XML::LibXML::Parser on parsing from different
  37
+    sources.
  38
+
  39
+    Returned data structure follows XML and its Schema, for example:
  40
+
  41
+        {
  42
+            'Case' => {
  43
+                'ID' => 'A1234567',
  44
+                'Status' => ...,
  45
+                ...
  46
+            },
  47
+            'Complainant' => {
  48
+                'Email' => 'antipiracy@contentowner.com',
  49
+                'Phone' => ...,
  50
+                ...
  51
+            },
  52
+            'Source' => {
  53
+                'TimeStamp' => '2003-08-30T12:34:53Z',
  54
+                'UserName' => 'guest',
  55
+                'Login' => { ... },
  56
+                'IP_Address' => ...,
  57
+                ...
  58
+            }
  59
+            'Service_Provider' => { ... }
  60
+            'Content' => {
  61
+                'Item' => [
  62
+                    {
  63
+                        'TimeStamp' => '2003-08-30T12:34:53Z',
  64
+                        'FileName' => '8Mile.mpg',
  65
+                        'Hash' => {
  66
+                                'Type' => 'SHA1',
  67
+                                '_' => 'EKR94KF985873KD930ER4KD94'
  68
+                              },
  69
+                        ...
  70
+                    },
  71
+                    { ... },
  72
+                    ...
  73
+                ]
  74
+            },
  75
+            'History' => {
  76
+                'Notice' => [
  77
+                    {
  78
+                        'ID' => '12321',
  79
+                        'TimeStamp' => '2003-08-30T10:23:13Z',
  80
+                        '_' => 'freeform text area'
  81
+                    },
  82
+                    { ... },
  83
+                    ...
  84
+                ]
  85
+            },
  86
+            'Notes' => '
  87
+                Open area for freeform text notes, filelists, etc...
  88
+            '
  89
+        }
  90
+
12 91
 AUTHOR
13 92
     Ruslan Zakirov <ruz@bestpractical.com>
14 93
 
104  lib/Parse/ACNS.pm
@@ -11,15 +11,24 @@ our $VERSION = '0.01';
11 11
 Parse::ACNS - parser for Automated Copyright Notice System (ACNS) XML
12 12
 
13 13
 =head1 SYNOPSIS
14  
-    
  14
+
15 15
     use Parse::ACNS;
16  
-    my $parser = Parse::ACNS->new(
17  
-        version => 'compat',
18  
-    );
19  
-    $parser->parse( );
  16
+    my $data = Parse::ACNS->new->parse( XML::LibXML->load_xml( string => $xml ) );
20 17
 
21 18
 =head1 DESCRIPTION
22 19
 
  20
+ACNS stands for Automated Copyright Notice System. It's an open source,
  21
+royalty free system that universities, ISP's, or anyone that handles large
  22
+volumes of copyright notices can implement on their network to increase
  23
+the efficiency and reduce the costs of responding to the notices... 
  24
+See "http://mpto.unistudios.com/xml/" for more details.
  25
+
  26
+This module parses ACNS XML into a perl data structure. Supports both 0.6 and
  27
+0.7 version. Parser strictly follows XML Schemas, so throws errors on malformed
  28
+data.
  29
+
  30
+However, it B<doesn't> extract ACNS XML from email messages.
  31
+
23 32
 =cut
24 33
 
25 34
 use File::ShareDir ();
@@ -31,6 +40,30 @@ use XML::Compile::Schema;
31 40
 our %CACHE = (
32 41
 );
33 42
 
  43
+=head1 METHODS
  44
+
  45
+=head2 new
  46
+
  47
+Constructor, takes list of named arguments.
  48
+
  49
+=over 4
  50
+
  51
+=item version - version of the specification
  52
+
  53
+=over 4
  54
+
  55
+=item compat - default value, can parse both 0.7 and 0.6 XML by making
  56
+TimeStamp element in Infringement/Content/Item optional. This is the
  57
+only difference between the spec versions.
  58
+
  59
+=item 0.7 or 0.6 - strict parsing of the specified version.
  60
+
  61
+=back
  62
+
  63
+=back
  64
+
  65
+=cut
  66
+
34 67
 sub new {
35 68
     my $proto = shift;
36 69
     return (bless { @_ }, ref($proto) || $proto)->init;
@@ -61,6 +94,67 @@ sub init {
61 94
     return $self;
62 95
 }
63 96
 
  97
+=head2 parse
  98
+
  99
+    my $data = Parse::ACNS->new->parse( XML::LibXML->load_xml(...) );
  100
+
  101
+Takes L<XML::LibXML::Document> containing an ACNS XML and returns it as a perl
  102
+struture. Read L<XML::LibXML::Parser> on parsing from different sources.
  103
+
  104
+Returned data structure follows XML and its Schema, for example:
  105
+
  106
+    {
  107
+        'Case' => {
  108
+            'ID' => 'A1234567',
  109
+            'Status' => ...,
  110
+            ...
  111
+        },
  112
+        'Complainant' => {
  113
+            'Email' => 'antipiracy@contentowner.com',
  114
+            'Phone' => ...,
  115
+            ...
  116
+        },
  117
+        'Source' => {
  118
+            'TimeStamp' => '2003-08-30T12:34:53Z',
  119
+            'UserName' => 'guest',
  120
+            'Login' => { ... },
  121
+            'IP_Address' => ...,
  122
+            ...
  123
+        }
  124
+        'Service_Provider' => { ... }
  125
+        'Content' => {
  126
+            'Item' => [
  127
+                {
  128
+                    'TimeStamp' => '2003-08-30T12:34:53Z',
  129
+                    'FileName' => '8Mile.mpg',
  130
+                    'Hash' => {
  131
+                            'Type' => 'SHA1',
  132
+                            '_' => 'EKR94KF985873KD930ER4KD94'
  133
+                          },
  134
+                    ...
  135
+                },
  136
+                { ... },
  137
+                ...
  138
+            ]
  139
+        },
  140
+        'History' => {
  141
+            'Notice' => [
  142
+                {
  143
+                    'ID' => '12321',
  144
+                    'TimeStamp' => '2003-08-30T10:23:13Z',
  145
+                    '_' => 'freeform text area'
  146
+                },
  147
+                { ... },
  148
+                ...
  149
+            ]
  150
+        },
  151
+        'Notes' => '
  152
+            Open area for freeform text notes, filelists, etc...
  153
+        '
  154
+    }
  155
+
  156
+=cut
  157
+
64 158
 sub parse {
65 159
     my $self = shift;
66 160
     return $self->{'reader'}->( shift );

0 notes on commit e966694

Please sign in to comment.
Something went wrong with that request. Please try again.