File: README

package info (click to toggle)
libxml-atom-owl-perl 0.103-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 344 kB
  • sloc: perl: 3,903; makefile: 11
file content (182 lines) | stat: -rw-r--r-- 6,116 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
NAME
    XML::Atom::OWL - parse an Atom file into RDF

SYNOPSIS
     use XML::Atom::OWL;
 
     $parser = XML::Atom::OWL->new($xml, $baseuri);
     $graph  = $parser->graph;

DESCRIPTION
    This has a pretty similar interface to RDF::RDFa::Parser.

  Constructor
    "new($xml, $baseuri, \%options, $storage)"
        This method creates a new XML::Atom::OWL object and returns it.

        The $xml variable may contain an XML (Atom) string, or an
        XML::LibXML::Document object. If a string, the document is parsed
        using XML::LibXML, which will throw an exception if it is not
        well-formed. XML::Atom::OWL does not catch the exception.

        The base URI is used to resolve relative URIs found in the document.

        Currently only one option is defined, 'no_fetch_content_src', a
        boolean indicating whether <content src> URLs should be
        automatically fetched and added to the model as if inline content
        had been provided. They are fetched by default, but it's pretty rare
        for feeds to include this attribute.

        $storage is an RDF::Trine::Storage object. If undef, then a new
        temporary store is created.

  Public Methods
    "uri"
        Returns the base URI of the document being parsed. This will usually
        be the same as the base URI provided to the constructor.

        Optionally it may be passed a parameter - an absolute or relative
        URI - in which case it returns the same URI which it was passed as a
        parameter, but as an absolute URI, resolved relative to the
        document's base URI.

        This seems like two unrelated functions, but if you consider the
        consequence of passing a relative URI consisting of a zero-length
        string, it in fact makes sense.

    "dom"
        Returns the parsed XML::LibXML::Document.

    "graph"
        This method will return an RDF::Trine::Model object with all
        statements of the full graph.

        This method automatically calls "consume".

    "root_identifier"
        Returns the blank node or URI for the root element of the Atom
        document as an RDF::Trine::Node

        Calls "consume" automatically.

    "set_callbacks(\%callbacks)"
        Set callback functions for the parser to call on certain events.
        These are only necessary if you want to do something especially
        unusual.

          $p->set_callbacks({
            'pretriple_resource' => sub { ... } ,
            'pretriple_literal'  => sub { ... } ,
            'ontriple'           => undef ,
            });

        For details of the callback functions, see the section CALLBACKS.
        "set_callbacks" must be used *before* "consume". "set_callbacks"
        itself returns a reference to the parser object itself.

    "consume"
        The document is parsed. Triples extracted from the document are
        passed to the callbacks as each one is found; triples are made
        available in the model returned by the "graph" method.

        This function returns the parser object itself, making it easy to
        abbreviate several of XML::Atom::OWL's functions:

          my $iterator = XML::Atom::OWL->new(undef, $uri)
                         ->consume->graph->as_stream;

        You probably only need to call this explicitly if you're using
        callbacks.

CALLBACKS
    Several callback functions are provided. These may be set using the
    "set_callbacks" function, which taskes a hashref of keys pointing to
    coderefs. The keys are named for the event to fire the callback on.

  pretriple_resource
    This is called when a triple has been found, but before preparing the
    triple for adding to the model. It is only called for triples with a
    non-literal object value.

    The parameters passed to the callback function are:

    *   A reference to the "XML::Atom::OWL" object

    *   A reference to the "XML::LibXML::Element" being parsed

    *   Subject URI or bnode (string)

    *   Predicate URI (string)

    *   Object URI or bnode (string)

    *   Graph URI or bnode (string or undef)

    The callback should return 1 to tell the parser to skip this triple (not
    add it to the graph); return 0 otherwise.

  pretriple_literal
    This is the equivalent of pretriple_resource, but is only called for
    triples with a literal object value.

    The parameters passed to the callback function are:

    *   A reference to the "XML::Atom::OWL" object

    *   A reference to the "XML::LibXML::Element" being parsed

    *   Subject URI or bnode (string)

    *   Predicate URI (string)

    *   Object literal (string)

    *   Datatype URI (string or undef)

    *   Language (string or undef)

    *   Graph URI or bnode (string or undef)

    Beware: sometimes both a datatype *and* a language will be passed. This
    goes beyond the normal RDF data model.)

    The callback should return 1 to tell the parser to skip this triple (not
    add it to the graph); return 0 otherwise.

  ontriple
    This is called once a triple is ready to be added to the graph. (After
    the pretriple callbacks.) The parameters passed to the callback function
    are:

    *   A reference to the "XML::Atom::OWL" object

    *   A reference to the "XML::LibXML::Element" being parsed

    *   An RDF::Trine::Statement object.

    The callback should return 1 to tell the parser to skip this triple (not
    add it to the graph); return 0 otherwise. The callback may modify the
    RDF::Trine::Statement object.

BUGS
    Please report any bugs to <http://rt.cpan.org/>.

SEE ALSO
    RDF::Trine, XML::Atom::FromOWL.

    <http://www.perlrdf.org/>.

AUTHOR
    Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE
    Copyright 2010-2011 Toby Inkster

    This library is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

DISCLAIMER OF WARRANTIES
    THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
    WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
    MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.