CONTRIBUTING 000664 001750 001750 6146 12404270735 14157 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 NAME
CONTRIBUTING
DESCRIPTION
If you're reading this document, that means you might be thinking about
helping me out with this project. Thanks!
Here's some ways you could help out:
* Bug reports
Found a bug? Great! (Well, not so great I suppose.)
The place to report them is . Don't e-mail me
about it, as your e-mail is more than likely to get lost amongst the
spam.
An example script clearly demonstrating the bug (preferably written
using Test::More) would be greatly appreciated.
* Patches
If you've found a bug and written a fix for it, even better!
Generally speaking you should check out the latest copy of the code
from the source repository rather than using the CPAN distribution.
The file META.yml should contain a link to the source repository. If
not, then try or submit a bug report.
(As far as I'm concerned the lack of a link is a bug.) Many of my
distributions are also mirrored at .
To submit the patch, do a pull request on GitHub or Bitbucket, or
attach a diff file to a bug report. Unless otherwise stated, I'll
assume that your contributions are licensed under the same terms as
the rest of the project.
(If using git, feel free to work in a branch. For Mercurial, I'd
prefer bookmarks within the default branch.)
* Documentation
If there's anything unclear in the documentation, please submit this
as a bug report or patch as above.
Non-toy example scripts that I can bundle would also be appreciated.
* Translation
Translations of documentation would be welcome.
For translations of error messages and other strings embedded in the
code, check with me first. Sometimes the English strings may not in
a stable state, so it would be a waste of time translating them.
Coding Style
I tend to write using something approximating the Allman style, using
tabs for indentation and Unix-style line breaks.
*
*
I nominally encode all source files as UTF-8, though in practice most of
them use a 7-bit-safe ASCII-compatible subset of UTF-8.
AUTHOR
Toby Inkster .
COPYRIGHT AND LICENCE
Copyright (c) 2012-2014 by Toby Inkster.
CONTRIBUTING is available under three different licences permitting its
redistribution: the CC-BY-SA_UK-2.0 licence, plus the same licences as
Perl itself, which is distributed under the GNU General Public Licence
version 1, and the Artistic Licence.
This file is licensed under the Creative Commons Attribution-ShareAlike
2.0 UK: England & Wales License. To view a copy of this license, visit
.
This file is free software; you can redistribute it and/or modify it
under the same terms as the Perl 5 programming language system itself.
COPYRIGHT 000664 001750 001750 2306 12404270735 13612 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: XML-Atom-OWL
Upstream-Contact: TOBYINK and Toby Inkster
Source: https://metacpan.org/release/XML-Atom-OWL
Files: CONTRIBUTING
INSTALL
LICENSE
TODO
examples/identica.pl
examples/simple_example.pl
Copyright: Unknown
License: Unknown
Files: Changes
META.json
META.yml
dist.ini
doap.ttl
Copyright: Copyright 2014 Toby Inkster.
License: GPL-1.0+ or Artistic-1.0
Files: COPYRIGHT
CREDITS
SIGNATURE
Copyright: None
License: public-domain
Files: README
lib/XML/Atom/OWL.pm
Copyright: Copyright 2010-2011 Toby Inkster.
License: GPL-1.0+ or Artistic-1.0
Files: t/01basic.t
Copyright: Copyright 2011 Toby Inkster.
License: GPL-1.0+ or Artistic-1.0
Files: Makefile.PL
Copyright: Copyright 2013 Toby Inkster.
License: GPL-1.0+ or Artistic-1.0
License: Artistic-1.0
This software is Copyright (c) 2014 by the copyright holder(s).
This is free software, licensed under:
The Artistic License 1.0
License: GPL-1.0
This software is Copyright (c) 2014 by the copyright holder(s).
This is free software, licensed under:
The GNU General Public License, Version 1, February 1989
CREDITS 000664 001750 001750 114 12404270730 13305 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 Maintainer:
- TOBYINK
- Toby Inkster
Changes 000664 001750 001750 2777 12404270730 13621 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 XML-Atom-OWL
============
Created: 2010-01-15
Home page:
Bug tracker:
Maintainer: Toby Inkster
0.104 2014-09-11
[ Packaging ]
- Switch to Dist::Inkt.
0.103 2011-10-27
[ Packaging ]
- Module::Package::RDF
[ Other ]
- Added: ActivityStrea.ms support.
- Updated: use 5.010
0.102 2011-03-05
[ Documentation ]
- Various formatting fixes and other minor improvements to documentation.
[ Other ]
- use Scalar::Util qw(blessed).
0.101 2010-07-19
[ Bug Fixes ]
- Fix packaging error; Makefile.PL and META.yml didn't note dependency on
common::sense.
0.100 2010-07-19
[ REGRESSIONS ]
- Switched to using common::sense instead of strict, but didn't note
change in Makefile.PL/META.yml
[ Other ]
- Automatically call 'consume' as required.
0.04 2010-04-29
- Keep base URI and lang information for element.
0.03 2010-04-28
- Added: Ability to automatically fetch links and include
the content as if it had been inline.
- Compliance improvements for element.
0.02 2010-01-23
- Added: Support arbitrary other extensions using XML literals.
- Added: Support for Atom License Extension
- Added: Support for Atom Threading Extension
- Added: Support for Feed Paging and Archiving
0.01 2010-01-18 First release
INSTALL 000664 001750 001750 1675 12404270726 13360 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 Installing XML-Atom-OWL should be straightforward.
INSTALLATION WITH CPANMINUS
If you have cpanm, you only need one line:
% cpanm XML::Atom::OWL
If you are installing into a system-wide directory, you may need to pass
the "-S" flag to cpanm, which uses sudo to install the module:
% cpanm -S XML::Atom::OWL
INSTALLATION WITH THE CPAN SHELL
Alternatively, if your CPAN shell is set up, you should just be able to
do:
% cpan XML::Atom::OWL
MANUAL INSTALLATION
As a last resort, you can manually install it. Download the tarball and
unpack it.
Consult the file META.json for a list of pre-requisites. Install these
first.
To build XML-Atom-OWL:
% perl Makefile.PL
% make && make test
Then install it:
% make install
If you are installing into a system-wide directory, you may need to run:
% sudo make install
LICENSE 000664 001750 001750 43655 12404270726 13360 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 This software is copyright (c) 2014 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
Terms of the Perl programming language system itself
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
b) the "Artistic License"
--- The GNU General Public License, Version 1, February 1989 ---
This software is Copyright (c) 2014 by Toby Inkster.
This is free software, licensed under:
The GNU General Public License, Version 1, February 1989
GNU GENERAL PUBLIC LICENSE
Version 1, February 1989
Copyright (C) 1989 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The license agreements of most software companies try to keep users
at the mercy of those companies. By contrast, our General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. The
General Public License applies to the Free Software Foundation's
software and to any other program whose authors commit to using it.
You can use it for your programs, too.
When we speak of free software, we are referring to freedom, not
price. Specifically, the General Public License is designed to make
sure that you have the freedom to give away or sell copies of free
software, that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of a such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must tell them their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
distributed under the terms of this General Public License. The
"Program", below, refers to any such program or work, and a "work based
on the Program" means either the Program or any work containing the
Program or a portion of it, either verbatim or with modifications. Each
licensee is addressed as "you".
1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this
General Public License and to the absence of any warranty; and give any
other recipients of the Program a copy of this General Public License
along with the Program. You may charge a fee for the physical act of
transferring a copy.
2. You may modify your copy or copies of the Program or any portion of
it, and copy and distribute such modifications under the terms of Paragraph
1 above, provided that you also do the following:
a) cause the modified files to carry prominent notices stating that
you changed the files and the date of any change; and
b) cause the whole of any work that you distribute or publish, that
in whole or in part contains the Program or any part thereof, either
with or without modifications, to be licensed at no charge to all
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
Public License.
d) You may charge a fee for the physical act of transferring a
copy, and you may at your option offer warranty protection in
exchange for a fee.
Mere aggregation of another independent work with the Program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other work under the scope of these terms.
3. You may copy and distribute the Program (or a portion or derivative of
it, under Paragraph 2) in object code or executable form under the terms of
Paragraphs 1 and 2 above provided that you also do one of the following:
a) accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of
Paragraphs 1 and 2 above; or,
b) accompany it with a written offer, valid for at least three
years, to give any third party free (except for a nominal charge
for the cost of distribution) a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of
Paragraphs 1 and 2 above; or,
c) accompany it with the information you received as to where the
corresponding source code may be obtained. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form alone.)
Source code for a work means the preferred form of the work for making
modifications to it. For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.
4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.
7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of the license which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
the license, you may choose any version ever published by the Free Software
Foundation.
8. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C) 19yy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
program `Gnomovision' (a program to direct compilers to make passes
at assemblers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
That's all there is to it!
--- The Artistic License 1.0 ---
This software is Copyright (c) 2014 by Toby Inkster.
This is free software, licensed under:
The Artistic License 1.0
The Artistic License
Preamble
The intent of this document is to state the conditions under which a Package
may be copied, such that the Copyright Holder maintains some semblance of
artistic control over the development of the package, while giving the users of
the package the right to use and distribute the Package in a more-or-less
customary fashion, plus the right to make reasonable modifications.
Definitions:
- "Package" refers to the collection of files distributed by the Copyright
Holder, and derivatives of that collection of files created through
textual modification.
- "Standard Version" refers to such a Package if it has not been modified,
or has been modified in accordance with the wishes of the Copyright
Holder.
- "Copyright Holder" is whoever is named in the copyright or copyrights for
the package.
- "You" is you, if you're thinking about copying or distributing this Package.
- "Reasonable copying fee" is whatever you can justify on the basis of media
cost, duplication charges, time of people involved, and so on. (You will
not be required to justify it to the Copyright Holder, but only to the
computing community at large as a market that must bear the fee.)
- "Freely Available" means that no fee is charged for the item itself, though
there may be fees involved in handling the item. It also means that
recipients of the item may redistribute it under the same conditions they
received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications derived
from the Public Domain or from the Copyright Holder. A Package modified in such
a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided that
you insert a prominent notice in each changed file stating how and when you
changed that file, and provided that you do at least ONE of the following:
a) place your modifications in the Public Domain or otherwise make them
Freely Available, such as by posting said modifications to Usenet or an
equivalent medium, or placing the modifications on a major archive site
such as ftp.uu.net, or by allowing the Copyright Holder to include your
modifications in the Standard Version of the Package.
b) use the modified Package only within your corporation or organization.
c) rename any non-standard executables so the names do not conflict with
standard executables, which must also be provided, and provide a separate
manual page for each non-standard executable that clearly documents how it
differs from the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or executable
form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where to
get the Standard Version.
b) accompany the distribution with the machine-readable source of the Package
with your modifications.
c) accompany any non-standard executables with their corresponding Standard
Version executables, giving the non-standard executables non-standard
names, and clearly documenting the differences in manual pages (or
equivalent), together with instructions on where to get the Standard
Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this Package. You
may not charge a fee for this Package itself. However, you may distribute this
Package in aggregate with other (possibly commercial) programs as part of a
larger (possibly commercial) software distribution provided that you do not
advertise this Package as a product of your own.
6. The scripts and library files supplied as input to or produced as output
from the programs of this Package do not automatically fall under the copyright
of this Package, but belong to whomever generated them, and may be sold
commercially, and may be aggregated with this Package.
7. C or perl subroutines supplied by you and linked into this Package shall not
be considered part of this Package.
8. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
9. 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.
The End
MANIFEST 000664 001750 001750 327 12404270735 13431 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 CONTRIBUTING
COPYRIGHT
CREDITS
Changes
INSTALL
LICENSE
MANIFEST
META.json
META.yml
Makefile.PL
README
SIGNATURE
TODO
dist.ini
doap.ttl
examples/identica.pl
examples/simple_example.pl
lib/XML/Atom/OWL.pm
t/01basic.t
META.json 000664 001750 001750 4113 12404270735 13736 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 {
"abstract" : "parse an Atom file into RDF",
"author" : [
"Toby Inkster ",
"TOBYINK "
],
"dynamic_config" : 0,
"generated_by" : "Moose::Meta::Class::__ANON__::SERIAL::12 version , CPAN::Meta::Converter version 2.140640",
"keywords" : [
"ActivityStrea.ms",
"Atom",
"AtomOWL",
"Feed",
"OWL",
"RDF",
"Syndication"
],
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "XML-Atom-OWL",
"no_index" : {
"directory" : [
"eg",
"examples",
"inc",
"t",
"xt"
]
},
"optional_features" : {},
"prereqs" : {
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "6.17"
}
},
"runtime" : {
"requires" : {
"Carp" : "1.00",
"DateTime" : "0",
"Encode" : "0",
"HTTP::Link::Parser" : "0.100",
"LWP::UserAgent" : "0",
"MIME::Base64" : "0",
"RDF::Trine" : "0.135",
"Scalar::Util" : "0",
"URI" : "1.30",
"URI::URL" : "0",
"XML::LibXML" : "1.70",
"common::sense" : "0"
}
},
"test" : {
"requires" : {
"Test::More" : "0.61"
}
}
},
"provides" : {
"XML::Atom::OWL" : {
"file" : "lib/XML/Atom/OWL.pm",
"version" : "0.104"
}
},
"release_status" : "stable",
"resources" : {
"X_identifier" : "http://purl.org/NET/cpan-uri/dist/XML-Atom-OWL/project",
"bugtracker" : {
"web" : "http://rt.cpan.org/Dist/Display.html?Queue=XML-Atom-OWL"
},
"homepage" : "https://metacpan.org/release/XML-Atom-OWL",
"license" : [
"http://dev.perl.org/licenses/"
],
"repository" : {
"type" : "svn",
"web" : "http://goddamn.co.uk/svn-web/perlmods/browse/XML-Atom-OWL/"
}
},
"version" : "0.104"
}
META.yml 000664 001750 001750 2431 12404270735 13567 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 ---
abstract: 'parse an Atom file into RDF'
author:
- 'Toby Inkster '
- 'TOBYINK '
build_requires:
Test::More: '0.61'
configure_requires:
ExtUtils::MakeMaker: '6.17'
dynamic_config: 0
generated_by: 'Moose::Meta::Class::__ANON__::SERIAL::12 version , CPAN::Meta::Converter version 2.140640'
keywords:
- ActivityStrea.ms
- Atom
- AtomOWL
- Feed
- OWL
- RDF
- Syndication
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: XML-Atom-OWL
no_index:
directory:
- eg
- examples
- inc
- t
- xt
optional_features: {}
provides:
XML::Atom::OWL:
file: lib/XML/Atom/OWL.pm
version: '0.104'
requires:
Carp: '1.00'
DateTime: '0'
Encode: '0'
HTTP::Link::Parser: '0.100'
LWP::UserAgent: '0'
MIME::Base64: '0'
RDF::Trine: '0.135'
Scalar::Util: '0'
URI: '1.30'
URI::URL: '0'
XML::LibXML: '1.70'
common::sense: '0'
resources:
X_identifier: http://purl.org/NET/cpan-uri/dist/XML-Atom-OWL/project
bugtracker: http://rt.cpan.org/Dist/Display.html?Queue=XML-Atom-OWL
homepage: https://metacpan.org/release/XML-Atom-OWL
license: http://dev.perl.org/licenses/
repository: http://goddamn.co.uk/svn-web/perlmods/browse/XML-Atom-OWL/
version: '0.104'
Makefile.PL 000664 001750 001750 13216 12404270735 14313 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 use strict;
use ExtUtils::MakeMaker 6.17;
my $EUMM = eval( $ExtUtils::MakeMaker::VERSION );
my $meta = {
"abstract" => "parse an Atom file into RDF",
"author" => [
"Toby Inkster ",
"TOBYINK ",
],
"dynamic_config" => 0,
"generated_by" => "Moose::Meta::Class::__ANON__::SERIAL::12 version , CPAN::Meta::Converter version 2.140640",
"keywords" => [
"ActivityStrea.ms",
"Atom",
"AtomOWL",
"Feed",
"OWL",
"RDF",
"Syndication",
],
"license" => ["perl_5"],
"meta-spec" => {
url => "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
version => 2,
},
"name" => "XML-Atom-OWL",
"no_index" => { directory => ["eg", "examples", "inc", "t", "xt"] },
"prereqs" => {
configure => { requires => { "ExtUtils::MakeMaker" => 6.17 } },
runtime => {
requires => {
"Carp" => "1.00",
"common::sense" => 0,
"DateTime" => 0,
"Encode" => 0,
"HTTP::Link::Parser" => "0.100",
"LWP::UserAgent" => 0,
"MIME::Base64" => 0,
"RDF::Trine" => 0.135,
"Scalar::Util" => 0,
"URI" => "1.30",
"URI::URL" => 0,
"XML::LibXML" => "1.70",
},
},
test => { requires => { "Test::More" => 0.61 } },
},
"provides" => {
"XML::Atom::OWL" => { file => "lib/XML/Atom/OWL.pm", version => 0.104 },
},
"release_status" => "stable",
"resources" => {
bugtracker => {
web => "http://rt.cpan.org/Dist/Display.html?Queue=XML-Atom-OWL",
},
homepage => "https://metacpan.org/release/XML-Atom-OWL",
license => ["http://dev.perl.org/licenses/"],
repository => {
type => "svn",
web => "http://goddamn.co.uk/svn-web/perlmods/browse/XML-Atom-OWL/",
},
X_identifier => "http://purl.org/NET/cpan-uri/dist/XML-Atom-OWL/project",
},
"version" => 0.104,
};
my %dynamic_config;
my %WriteMakefileArgs = (
ABSTRACT => $meta->{abstract},
AUTHOR => ($EUMM >= 6.5702 ? $meta->{author} : $meta->{author}[0]),
DISTNAME => $meta->{name},
VERSION => $meta->{version},
EXE_FILES => [ map $_->{file}, values %{ $meta->{x_provides_scripts} || {} } ],
NAME => do { my $n = $meta->{name}; $n =~ s/-/::/g; $n },
test => { TESTS => "t/*.t" },
%dynamic_config,
);
$WriteMakefileArgs{LICENSE} = $meta->{license}[0] if $EUMM >= 6.3001;
sub deps
{
my %r;
for my $stage (@_)
{
for my $dep (keys %{$meta->{prereqs}{$stage}{requires}})
{
next if $dep eq 'perl';
my $ver = $meta->{prereqs}{$stage}{requires}{$dep};
$r{$dep} = $ver if !exists($r{$dep}) || $ver >= $r{$dep};
}
}
\%r;
}
my ($build_requires, $configure_requires, $runtime_requires, $test_requires);
if ($EUMM >= 6.6303)
{
$WriteMakefileArgs{BUILD_REQUIRES} ||= deps('build');
$WriteMakefileArgs{CONFIGURE_REQUIRES} ||= deps('configure');
$WriteMakefileArgs{TEST_REQUIRES} ||= deps('test');
$WriteMakefileArgs{PREREQ_PM} ||= deps('runtime');
}
elsif ($EUMM >= 6.5503)
{
$WriteMakefileArgs{BUILD_REQUIRES} ||= deps('build', 'test');
$WriteMakefileArgs{CONFIGURE_REQUIRES} ||= deps('configure');
$WriteMakefileArgs{PREREQ_PM} ||= deps('runtime');
}
elsif ($EUMM >= 6.52)
{
$WriteMakefileArgs{CONFIGURE_REQUIRES} ||= deps('configure');
$WriteMakefileArgs{PREREQ_PM} ||= deps('runtime', 'build', 'test');
}
else
{
$WriteMakefileArgs{PREREQ_PM} ||= deps('configure', 'build', 'test', 'runtime');
}
{
my ($minperl) = reverse sort(
grep defined && /^[0-9]+(\.[0-9]+)?$/,
map $meta->{prereqs}{$_}{requires}{perl},
qw( configure build runtime )
);
if (defined($minperl))
{
die "Installing $meta->{name} requires Perl >= $minperl"
unless $] >= $minperl;
$WriteMakefileArgs{MIN_PERL_VERSION} ||= $minperl
if $EUMM >= 6.48;
}
}
sub FixMakefile
{
return unless -d 'inc';
my $file = shift;
local *MAKEFILE;
open MAKEFILE, "< $file" or die "FixMakefile: Couldn't open $file: $!; bailing out";
my $makefile = do { local $/; };
close MAKEFILE or die $!;
$makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /;
$makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g;
$makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g;
$makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m;
$makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m;
open MAKEFILE, "> $file" or die "FixMakefile: Couldn't open $file: $!; bailing out";
print MAKEFILE $makefile or die $!;
close MAKEFILE or die $!;
}
my $mm = WriteMakefile(%WriteMakefileArgs);
FixMakefile($mm->{FIRST_MAKEFILE} || 'Makefile');
exit(0);
README 000664 001750 001750 13730 12404270726 13222 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 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 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 .
SEE ALSO
RDF::Trine, XML::Atom::FromOWL.
.
AUTHOR
Toby Inkster .
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.
SIGNATURE 000664 001750 001750 3324 12404270736 13605 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 This file contains message digests of all files listed in MANIFEST,
signed via the Module::Signature module, version 0.73.
To verify the content in this distribution, first make sure you have
Module::Signature installed, then type:
% cpansign -v
It will check each file's integrity, as well as the signature's
validity. If "==> Signature verified OK! <==" is not displayed,
the distribution may already have been compromised, and you should
not run its Makefile.PL or Build.PL.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
SHA1 33317486c4fa2cf7fec85bf92ed38ac0f64233a0 CONTRIBUTING
SHA1 dc7074e0b10e84dad7b999a415528208841b30dd COPYRIGHT
SHA1 540e627824058dc4b3f75009923f7af8f8e388c8 CREDITS
SHA1 f291ebf2fab9418c0e7cab3975edd8e965190218 Changes
SHA1 adfa712345ef85b70b3c253b53bc11e4698820b1 INSTALL
SHA1 34f5e12514b91055de4b164a1f2327ef5c30ba53 LICENSE
SHA1 092e1886fd9baa742234e5387c2ab6802eb97d59 MANIFEST
SHA1 5a8d4f8fec6e644facf234fd1063d1c82d103dd0 META.json
SHA1 0918fe94a0addce66bdfbab8319aa5d352fcf519 META.yml
SHA1 07ee155d21ce9827d190ad727beb9504ea4860c1 Makefile.PL
SHA1 d8fb914b6582fc142f2a82ee82594128d915239c README
SHA1 ca0c7aae46fa685d14a1317c019badaa8c88d5fe TODO
SHA1 674034d4c12e7a0de08aa1fa2101e458771bf020 dist.ini
SHA1 b63813eb9f6c05bde3bc16e8a18ac0824fb4570f doap.ttl
SHA1 63780e60ef721a18013dd575d7668f336315d54a examples/identica.pl
SHA1 9e5d9a0ef1a1173896c83ca0abbb1bf45e4074fb examples/simple_example.pl
SHA1 0e60b04d952b84319b701b46ef2af68e0aced4b9 lib/XML/Atom/OWL.pm
SHA1 37ab48ecfd43df3754f6e186984e93bc74b7f807 t/01basic.t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iEUEARECAAYFAlQRcd4ACgkQzr+BKGoqfTmZgwCXaFjjkgc0eBW2xqLxsWLbeB2N
HgCbBNd853GAHKPHFeWJf9soVKV76tQ=
=1B9s
-----END PGP SIGNATURE-----
TODO 000664 001750 001750 71 12404270726 12744 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 - Support
- Perhaps support PoCo in Atom?
dist.ini 000664 001750 001750 75 12404270726 13724 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 ;;class='Dist::Inkt::Profile::TOBYINK'
;;name='XML-Atom-OWL'
doap.ttl 000664 001750 001750 21310 12404270735 14003 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104 @prefix dc: .
@prefix doap: .
@prefix doap-changeset: .
@prefix doap-deps: .
@prefix foaf: .
@prefix owl: .
@prefix rdfs: .
@prefix xsd: .
a doap:Project;
dc:contributor ;
doap-deps:runtime-requirement [ doap-deps:on "Carp 1.00"^^doap-deps:CpanId ], [ doap-deps:on "common::sense 0"^^doap-deps:CpanId ], [ doap-deps:on "URI::URL 0"^^doap-deps:CpanId ], [ doap-deps:on "XML::LibXML 1.70"^^doap-deps:CpanId ], [ doap-deps:on "DateTime 0"^^doap-deps:CpanId ], [ doap-deps:on "Encode 0"^^doap-deps:CpanId ], [
doap-deps:on "HTTP::Link::Parser 0.100"^^doap-deps:CpanId;
], [ doap-deps:on "LWP::UserAgent 0"^^doap-deps:CpanId ], [ doap-deps:on "MIME::Base64 0"^^doap-deps:CpanId ], [ doap-deps:on "RDF::Trine 0.135"^^doap-deps:CpanId ], [ doap-deps:on "Scalar::Util 0"^^doap-deps:CpanId ], [ doap-deps:on "URI 1.30"^^doap-deps:CpanId ];
doap-deps:test-requirement [ doap-deps:on "Test::More 0.61"^^doap-deps:CpanId ];
doap:bug-database ;
doap:category [ rdfs:label "Atom"@en ], [ rdfs:label "AtomOWL"@en ], [ rdfs:label "RDF"@en ], [ rdfs:label "Feed"@en ], [ rdfs:label "Syndication"@en ], [ rdfs:label "OWL"@en ], [ rdfs:label "ActivityStrea.ms" ];
doap:created "2010-01-15"^^xsd:date;
doap:developer ;
doap:documenter ;
doap:download-page ;
doap:homepage ;
doap:license ;
doap:maintainer ;
doap:name "XML-Atom-OWL";
doap:programming-language "Perl";
doap:release , , , , , , , , ;
doap:repository [
a doap:SVNRepository;
doap:browse ;
];
doap:shortdesc "parse an Atom file into RDF"@en;
doap:tester .
a doap:Version;
rdfs:label "First release"@en;
dc:issued "2010-01-18"^^xsd:date;
doap:file-release ;
doap:revision "0.01"^^xsd:string.
a doap:Version;
dc:issued "2010-01-23"^^xsd:date;
doap-changeset:changeset [
a doap-changeset:ChangeSet;
doap-changeset:item [
a doap-changeset:Addition;
rdfs:label "Support for Atom Threading Extension"@en;
rdfs:seeAlso ;
], [
a doap-changeset:Addition;
rdfs:label "Support for Feed Paging and Archiving"@en;
rdfs:seeAlso ;
], [
a doap-changeset:Addition;
rdfs:label "Support for Atom License Extension"@en;
rdfs:seeAlso ;
], [
a doap-changeset:Addition;
rdfs:label "Support arbitrary other extensions using XML literals."@en;
];
doap-changeset:versus ;
];
doap:file-release ;
doap:revision "0.02"^^xsd:string.
a doap:Version;
dc:issued "2010-04-28"^^xsd:date;
doap-changeset:changeset [
a doap-changeset:ChangeSet;
doap-changeset:item [
a doap-changeset:Addition;
rdfs:label "Ability to automatically fetch links and include the content as if it had been inline."@en;
], [
rdfs:label "Compliance improvements for element."@en;
];
doap-changeset:versus ;
];
doap:file-release ;
doap:revision "0.03"^^xsd:string.
a doap:Version;
dc:issued "2010-04-29"^^xsd:date;
doap-changeset:changeset [
a doap-changeset:ChangeSet;
doap-changeset:item [
rdfs:label "Keep base URI and lang information for element."@en;
rdfs:comment "Useful for XML-Atom-Microformats."@en;
];
doap-changeset:versus ;
];
doap:file-release ;
doap:revision "0.04"^^xsd:string.
a doap:Version;
dc:issued "2010-07-19"^^xsd:date;
doap-changeset:changeset [
a doap-changeset:ChangeSet;
doap-changeset:item [
rdfs:label "Automatically call 'consume' as required."@en;
], [
a doap-changeset:Regression;
rdfs:label "Switched to using common::sense instead of strict, but didn't note change in Makefile.PL/META.yml"@en;
];
doap-changeset:versus ;
];
doap:file-release ;
doap:revision "0.100"^^xsd:string.
a doap:Version;
dc:issued "2010-07-19"^^xsd:date;
doap-changeset:changeset [
a doap-changeset:ChangeSet;
doap-changeset:item [
a doap-changeset:Bugfix;
rdfs:label "Fix packaging error; Makefile.PL and META.yml didn't note dependency on common::sense."@en;
];
doap-changeset:versus ;
];
doap:file-release ;
doap:revision "0.101"^^xsd:string.
a doap:Version;
dc:issued "2011-03-05"^^xsd:date;
doap-changeset:changeset [
a doap-changeset:ChangeSet;
doap-changeset:item [
a doap-changeset:Documentation;
rdfs:label "Various formatting fixes and other minor improvements to documentation."@en;
], [ rdfs:label "use Scalar::Util qw(blessed)."@en ];
doap-changeset:versus ;
];
doap:file-release ;
doap:revision "0.102"^^xsd:string.
a doap:Version;
dc:issued "2011-10-27"^^xsd:date;
doap-changeset:changeset [
a doap-changeset:ChangeSet;
doap-changeset:item [
a doap-changeset:Addition;
rdfs:label "ActivityStrea.ms support."@en;
], [
a doap-changeset:Packaging;
rdfs:label "Module::Package::RDF"@en;
], [
a doap-changeset:Update;
rdfs:label "use 5.010"@en;
];
doap-changeset:versus ;
];
doap:file-release ;
doap:revision "0.103"^^xsd:string.
a doap:Version;
dc:identifier "XML-Atom-OWL-0.104"^^xsd:string;
dc:issued "2014-09-11"^^xsd:date;
doap-changeset:changeset [
doap-changeset:item [
a doap-changeset:Packaging;
rdfs:label "Switch to Dist::Inkt.";
];
];
doap-changeset:released-by ;
doap:file-release ;
doap:revision "0.104"^^xsd:string.
a foaf:Person;
foaf:homepage ;
foaf:mbox ;
foaf:name "Toby Inkster";
foaf:page ;
owl:sameAs .
identica.pl 000664 001750 001750 306 12404270726 16230 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104/examples #!/usr/bin/perl
use XML::Atom::OWL;
use RDF::TrineShortcuts;
my $p = XML::Atom::OWL->new(undef, 'http://identi.ca/api/statuses/user_timeline/36737.atom');
print rdf_string($p->graph => 'Turtle');
simple_example.pl 000664 001750 001750 4026 12404270726 17477 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104/examples use lib "lib";
use XML::Atom::OWL;
use JSON;
my $atom = <dive into mark
A <em>lot</em> of effort
went into making this effortless
2005-07-31T12:29:29Ztag:example.org,2003:3Copyright (c) 2003, Mark Pilgrim
Example Toolkit
Atom draft-07 snapshottag:example.org,2003:3.23972005-07-31T12:29:29Z2003-12-13T08:29:29-04:00Mark Pilgrimhttp://example.org/f8dy@example.comSam RubyJoe Gregorio
[Update: The Atom draft is finished.]
http://example.net/id/2
ATOM
my $awol = XML::Atom::OWL->new($atom, 'http://example.net/')->consume;
print to_json($awol->graph->as_hashref, {pretty=>1,canonical=>1});
01basic.t 000664 001750 001750 100 12404270726 14137 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104/t use Test::More tests => 1;
BEGIN { use_ok('XML::Atom::OWL') };
OWL.pm 000664 001750 001750 112101 12404270726 15457 0 ustar 00tai tai 000000 000000 XML-Atom-OWL-0.104/lib/XML/Atom package XML::Atom::OWL;
use 5.010;
use common::sense;
use Carp 1.00;
use DateTime 0;
use Encode 0 qw(encode_utf8);
use HTTP::Link::Parser 0.100;
use LWP::UserAgent 0;
use MIME::Base64 0 qw(decode_base64);
use RDF::Trine 0.135;
use Scalar::Util 0 qw(blessed);
use URI 1.30;
use XML::LibXML 1.70 qw(:all);
use constant AAIR_NS => 'http://xmlns.notu.be/aair#';
use constant ATOM_NS => 'http://www.w3.org/2005/Atom';
use constant AWOL_NS => 'http://bblfish.net/work/atom-owl/2006-06-06/#';
use constant AS_NS => 'http://activitystrea.ms/spec/1.0/';
use constant AX_NS => 'http://buzzword.org.uk/rdf/atomix#';
use constant FH_NS => 'http://purl.org/syndication/history/1.0';
use constant FOAF_NS => 'http://xmlns.com/foaf/0.1/';
use constant IANA_NS => 'http://www.iana.org/assignments/relation/';
use constant RDF_NS => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
use constant RDF_TYPE => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
use constant THR_NS => 'http://purl.org/syndication/thread/1.0';
use constant XSD_NS => 'http://www.w3.org/2001/XMLSchema#';
our $VERSION = '0.104';
sub new
{
my $class = shift;
my $content = shift;
my $baseuri = shift;
my $options = shift || undef;
my $store = shift || undef;
my $domtree;
unless (defined $content)
{
my $ua = LWP::UserAgent->new;
$ua->agent(sprintf('%s/%s ', __PACKAGE__, $VERSION));
$ua->default_header("Accept" => "application/atom+xml, application/xml;q=0.1, text/xml;q=0.1");
my $response = $ua->get($baseuri);
croak "HTTP response not successful\n"
unless $response->is_success;
croak "Non-Atom HTTP response\n"
unless $response->content_type =~ m`^(text/xml)|(application/(atom\+xml|xml))$`;
$content = $response->decoded_content;
}
if (blessed($content) and $content->isa('XML::LibXML::Document'))
{
($domtree, $content) = ($content, $content->toString);
}
else
{
my $xml_parser = XML::LibXML->new;
$domtree = $xml_parser->parse_string($content);
}
$store = RDF::Trine::Store::DBI->temporary_store
unless defined $store;
my $self = bless {
'content' => $content,
'baseuri' => $baseuri,
'options' => $options,
'DOM' => $domtree,
'sub' => {},
'RESULTS' => RDF::Trine::Model->new($store),
}, $class;
return $self;
}
sub uri
{
my $this = shift;
my $param = shift || '';
my $opts = shift || {};
if ((ref $opts) =~ /^XML::LibXML/)
{
my $x = {'element' => $opts};
$opts = $x;
}
if ($param =~ /^([a-z][a-z0-9\+\.\-]*)\:/i)
{
# seems to be an absolute URI, so can safely return "as is".
return $param;
}
elsif ($opts->{'require-absolute'})
{
return undef;
}
my $base = $this->{baseuri};
if ($opts->{'element'})
{
$base = $this->get_node_base($opts->{'element'});
}
my $url = URI->new($param);
my $rv = $url->abs($base)->as_string;
while ($rv =~ m!^(http://.*)(\.\./|\.)+(\.\.|\.)?$!i)
{
$rv = $1;
}
return $rv;
}
sub dom
{
my $this = shift;
return $this->{DOM};
}
sub graph
{
my $this = shift;
$this->consume;
return $this->{RESULTS};
}
sub graphs
{
my $this = shift;
$this->consume;
return { $this->{'baseuri'} => $this->{RESULTS} };
}
sub root_identifier
{
my $self = shift;
$self->consume;
if ($self->{'root_identifier'} =~ /^_:(.*)/)
{
return RDF::Trine::Node::Blank->new($1);
}
else
{
return RDF::Trine::Node::Resource->new($self->{'root_identifier'});
}
}
sub set_callbacks
# Set callback functions for handling RDF triples.
{
my $this = shift;
if ('HASH' eq ref $_[0])
{
$this->{'sub'} = $_[0];
}
elsif (defined $_[0])
{
die("What kind of callback hashref was that??\n");
}
else
{
$this->{'sub'} = undef;
}
return $this;
}
sub consume
{
my $self = shift;
return $self if $self->{'comsumed'};
my $root = $self->dom->documentElement;
if ($root->namespaceURI eq ATOM_NS and $root->localname eq 'feed')
{
$self->{'root_identifier'} = $self->consume_feed($root);
}
elsif ($root->namespaceURI eq ATOM_NS and $root->localname eq 'entry')
{
$self->{'root_identifier'} = $self->consume_entry($root);
}
$self->{'comsumed'}++;
return $self;
}
sub consume_feed
{
my $self = shift;
my $feed = shift;
my $skip_entries = shift || 0;
# Feed
my $feed_identifier = $self->bnode($feed);
$self->rdf_triple($feed, $feed_identifier, RDF_TYPE, AWOL_NS.'Feed');
# Common stuff
$self->consume_feed_or_entry($feed, $feed_identifier);
# fh:archive and fh:complete
if ($feed->getChildrenByTagNameNS(FH_NS, 'archive'))
{
$self->rdf_triple($feed, $feed_identifier, RDF_TYPE, AX_NS.'ArchiveFeed');
}
my $complete = 0;
if ($feed->getChildrenByTagNameNS(FH_NS, 'complete'))
{
$complete = 1;
$self->rdf_triple($feed, $feed_identifier, RDF_TYPE, AX_NS.'CompleteFeed');
}
my $last_listid;
# entry
unless ($skip_entries)
{
my @elems = $feed->getChildrenByTagNameNS(ATOM_NS, 'entry');
foreach my $e (@elems)
{
my $entry_identifier = $self->consume_entry($e);
$self->rdf_triple($e, $feed_identifier, AWOL_NS.'entry', $entry_identifier);
# If this feed is known to be complete, include an rdf:List
# to assist in open-world reasoning.
if ($complete)
{
my $listid = $self->bnode;
if (defined $last_listid)
{
$self->rdf_triple($e, $last_listid, RDF_NS.'rest', $listid);
}
else
{
$self->rdf_triple($e, $feed_identifier, AX_NS.'entry-list', $listid);
}
$self->rdf_triple($e, $listid, RDF_TYPE, RDF_NS.'List');
$self->rdf_triple($e, $listid, RDF_NS.'first', $entry_identifier);
$last_listid = $listid;
}
}
}
if ($complete)
{
if (defined $last_listid)
{
$self->rdf_triple($feed, $last_listid, RDF_NS.'rest', RDF_NS.'nil');
}
else
{
$self->rdf_triple($feed, $feed_identifier, AX_NS.'entry-list', RDF_NS.'nil');
}
}
# icon and logo
foreach my $role (qw(icon logo))
{
my @elems = $feed->getChildrenByTagNameNS(ATOM_NS, $role);
foreach my $e (@elems)
{
my $img = $self->uri($e->textContent, $e);
$self->rdf_triple($e, $feed_identifier, AWOL_NS.$role, $img);
$self->rdf_triple($e, $img, RDF_TYPE, FOAF_NS.'Image');
}
}
# generator
{
my @elems = $feed->getChildrenByTagNameNS(ATOM_NS, 'generator');
foreach my $e (@elems)
{
my $gen_identifier = $self->consume_generator($e);
$self->rdf_triple($e, $feed_identifier, AWOL_NS.'generator', $gen_identifier);
}
}
# subtitle
{
my @elems = $feed->getChildrenByTagNameNS(ATOM_NS, 'subtitle');
foreach my $e (@elems)
{
my $content_identifier = $self->consume_textconstruct($e);
$self->rdf_triple($e, $feed_identifier, AWOL_NS.'subtitle', $content_identifier);
}
}
return $feed_identifier;
}
sub consume_entry
{
my $self = shift;
my $entry = shift;
# Entry
my $entry_identifier = $self->bnode($entry);
$self->rdf_triple($entry, $entry_identifier, RDF_TYPE, AWOL_NS.'Entry');
# Common stuff
$self->consume_feed_or_entry($entry, $entry_identifier);
# published
{
my @elems = $entry->getChildrenByTagNameNS(ATOM_NS, 'published');
foreach my $e (@elems)
{
$self->rdf_triple_literal($e, $entry_identifier, AWOL_NS.'published', $e->textContent, XSD_NS.'dateTime');
}
}
# summary
{
my @elems = $entry->getChildrenByTagNameNS(ATOM_NS, 'content');
foreach my $e (@elems)
{
my $content_identifier = $self->consume_content($e);
$self->rdf_triple($e, $entry_identifier, AWOL_NS.'content', $content_identifier);
}
}
# source
{
my @elems = $entry->getChildrenByTagNameNS(ATOM_NS, 'source');
foreach my $e (@elems)
{
my $feed_identifier = $self->consume_feed($e, 1);
$self->rdf_triple($e, $entry_identifier, AWOL_NS.'source', $feed_identifier);
}
}
# summary
{
my @elems = $entry->getChildrenByTagNameNS(ATOM_NS, 'summary');
foreach my $e (@elems)
{
my $content_identifier = $self->consume_textconstruct($e);
$self->rdf_triple($e, $entry_identifier, AWOL_NS.'summary', $content_identifier);
}
}
# thr:in-reply-to
{
my @elems = $entry->getChildrenByTagNameNS(THR_NS, 'in-reply-to');
foreach my $e (@elems)
{
my $irt_id = $self->consume_inreplyto($e);
$self->rdf_triple($e, $entry_identifier, AX_NS.'in-reply-to', $irt_id);
}
}
# thr:total
{
my @elems = $entry->getChildrenByTagNameNS(THR_NS, 'total');
foreach my $e (@elems)
{
my $total = $e->textContent;
$self->rdf_triple_literal($e, $entry_identifier, AX_NS.'total', $total, XSD_NS.'integer');
}
}
return $entry_identifier;
}
sub consume_feed_or_entry
{
my $self = shift;
my $fore = shift;
my $id = shift;
my @elems = $fore->getChildrenByTagNameNS(ATOM_NS, 'id');
foreach my $e (@elems)
{
my $_id = $self->uri($e->textContent, $e);
$self->rdf_triple_literal($e, $id, AWOL_NS.'id', $_id, XSD_NS.'anyURI');
}
my $is_as = 0;
# activitystreams:object, activitystreams:target
foreach my $role (qw(object target))
{
my @elems = $fore->getChildrenByTagNameNS(AS_NS, $role);
foreach my $e (@elems)
{
$is_as++;
my $obj_id = $self->consume_entry($e, $id);
$self->rdf_triple($e, $id, AAIR_NS.'activity'.ucfirst($role), $obj_id);
}
}
# activitystreams:verb
{
my @elems = $fore->getChildrenByTagNameNS(AS_NS, 'verb');
foreach my $e (@elems)
{
$is_as++;
my $url = $e->textContent;
$url =~ s/(^\s*)|(\s*$)//g;
$self->rdf_triple($e, $id, AAIR_NS.'activityVerb', URI->new($url)->abs('http://activitystrea.ms/schema/1.0/')->as_string);
}
if ($is_as && !@elems)
{
$self->rdf_triple($fore, $id, AAIR_NS.'activityVerb', "http://activitystrea.ms/schema/1.0/post");
}
}
# activitystreams:object-type
{
my @elems = $fore->getChildrenByTagNameNS(AS_NS, 'object-type');
foreach my $e (@elems)
{
my $url = $e->textContent;
$url =~ s/(^\s*)|(\s*$)//g;
$self->rdf_triple($e, $id, RDF_NS.'type', URI->new($url)->abs('http://activitystrea.ms/schema/1.0/')->as_string);
}
}
# authors and contributors
foreach my $role (qw(author contributor))
{
my @elems = $fore->getChildrenByTagNameNS(ATOM_NS, $role);
foreach my $e (@elems)
{
my $person_identifier = $self->consume_person($e);
$self->rdf_triple($e, $id, AWOL_NS.$role, $person_identifier);
if ($role eq 'author' and $is_as)
{
$self->rdf_triple($e, $person_identifier, RDF_NS.'type', AAIR_NS.'Actor');
$self->rdf_triple($e, $id, AAIR_NS.'activityActor', $person_identifier);
}
}
}
# updated
{
my @elems = $fore->getChildrenByTagNameNS(ATOM_NS, 'updated');
foreach my $e (@elems)
{
$self->rdf_triple_literal($e, $id, AWOL_NS.'updated', $e->textContent, XSD_NS.'dateTime');
}
}
# link
{
my @elems = $fore->getChildrenByTagNameNS(ATOM_NS, 'link');
foreach my $e (@elems)
{
my $link_identifier = $self->consume_link($e, $id);
$self->rdf_triple($e, $id, AWOL_NS.'link', $link_identifier);
}
}
# title and rights
foreach my $role (qw(title rights))
{
my @elems = $fore->getChildrenByTagNameNS(ATOM_NS, $role);
foreach my $e (@elems)
{
my $content_identifier = $self->consume_textconstruct($e);
$self->rdf_triple($e, $id, AWOL_NS.$role, $content_identifier);
}
}
# category
{
my @elems = $fore->getChildrenByTagNameNS(ATOM_NS, 'category');
foreach my $e (@elems)
{
my $cat_identifier = $self->consume_category($e, $id);
$self->rdf_triple($e, $id, AWOL_NS.'category', $cat_identifier);
}
}
# Unknown Extensions!
{
my @elems = $fore->getChildrenByTagName('*');
foreach my $e (@elems)
{
next if $e->namespaceURI eq ATOM_NS;
next if $e->namespaceURI eq AS_NS;
next if $e->namespaceURI eq FH_NS;
next if $e->namespaceURI eq THR_NS;
my $xml = $self->xmlify_inclusive($e);
$self->rdf_triple_literal($e, $id, AX_NS.'extension-element', $xml, RDF_NS.'XMLLiteral');
}
}
return $id;
}
sub consume_textconstruct
{
my $self = shift;
my $elem = shift;
my $id = $self->bnode($elem);
$self->rdf_triple($elem, $id, RDF_TYPE, AWOL_NS.'TextContent');
my $lang = $self->get_node_lang($elem);
if (lc $elem->getAttribute('type') eq 'xhtml')
{
my $cnt = $self->xmlify($elem, $lang);
$self->rdf_triple_literal($elem, $id, AWOL_NS.'xhtml', $cnt, RDF_NS.'XMLLiteral');
}
elsif (lc $elem->getAttribute('type') eq 'html')
{
my $cnt = $elem->textContent;
$self->rdf_triple_literal($elem, $id, AWOL_NS.'html', $cnt, undef, $lang);
}
else
{
my $cnt = $elem->textContent;
$self->rdf_triple_literal($elem, $id, AWOL_NS.'text', $cnt, undef, $lang);
}
return $id;
}
sub consume_content
{
my $self = shift;
my $elem = shift;
my $id = $self->bnode($elem);
$self->rdf_triple($elem, $id, RDF_TYPE, AWOL_NS.'Content');
my $lang = $self->get_node_lang($elem);
my $base = $self->get_node_base($elem);
if ($elem->hasAttribute('src'))
{
my $link = $self->uri($elem->getAttribute('src'), $elem);
$self->rdf_triple($elem, $id, AWOL_NS.'src', $link);
if ($self->{'options'}->{'no_fetch_content_src'})
{
$self->rdf_triple_literal($elem, $id, AWOL_NS.'type', $elem->getAttribute('type'))
if $elem->hasAttribute('type');
}
else
{
my $ua = LWP::UserAgent->new;
$ua->agent(sprintf('%s/%s ', __PACKAGE__, $VERSION));
if ($elem->hasAttribute('type'))
{
$ua->default_header("Accept" => $elem->getAttribute('type').", */*;q=0.1");
}
else
{
$ua->default_header("Accept" => "application/xhtml+xml, text/html, text/plain, */*;q=0.1");
}
my $response = $ua->get($self->uri($elem->getAttribute('src'), $elem));
if ($response->is_success)
{
$self->rdf_triple_literal($elem, $id, AWOL_NS.'body', $response->decoded_content);
if ($response->content_type)
{ $self->rdf_triple_literal($elem, $id, AWOL_NS.'type', $response->content_type); }
elsif ($elem->hasAttribute('type'))
{ $self->rdf_triple_literal($elem, $id, AWOL_NS.'type', $elem->getAttribute('type')); }
if ($response->content_language =~ /^\s*([a-z]{2,3})\b/i)
{ $self->rdf_triple_literal($elem, $id, AWOL_NS.'lang', lc $1, XSD_NS.'language'); }
if ($response->base)
{ $self->rdf_triple($elem, $id, AWOL_NS.'base', $response->base); }
}
else
{
$self->rdf_triple_literal($elem, $id, AWOL_NS.'type', $elem->getAttribute('type'))
if $elem->hasAttribute('type');
}
}
}
elsif (lc $elem->getAttribute('type') eq 'text' or !$elem->hasAttribute('type'))
{
my $cnt = $elem->textContent;
$self->rdf_triple_literal($elem, $id, AWOL_NS.'body', $cnt, undef, $lang);
$self->rdf_triple_literal($elem, $id, AWOL_NS.'type', 'text/plain');
$self->rdf_triple_literal($elem, $id, AWOL_NS.'lang', $lang, XSD_NS.'language') if $lang;
$self->rdf_triple($elem, $id, AWOL_NS.'base', $base) if $base;
}
elsif (lc $elem->getAttribute('type') eq 'xhtml')
{
my $cnt = $self->xmlify($elem, $lang);
$self->rdf_triple_literal($elem, $id, AWOL_NS.'body', $cnt, RDF_NS.'XMLLiteral');
$self->rdf_triple_literal($elem, $id, AWOL_NS.'type', 'application/xhtml+xml');
$self->rdf_triple_literal($elem, $id, AWOL_NS.'lang', $lang, XSD_NS.'language') if $lang;
$self->rdf_triple($elem, $id, AWOL_NS.'base', $base) if $base;
}
elsif (lc $elem->getAttribute('type') eq 'html')
{
my $cnt = $elem->textContent;
$self->rdf_triple_literal($elem, $id, AWOL_NS.'body', $cnt, undef, $lang);
$self->rdf_triple_literal($elem, $id, AWOL_NS.'type', 'text/html');
$self->rdf_triple_literal($elem, $id, AWOL_NS.'lang', $lang, XSD_NS.'language') if $lang;
$self->rdf_triple($elem, $id, AWOL_NS.'base', $base) if $base;
}
elsif ($elem->getAttribute('type') =~ m'([\+\/]xml)$'i)
{
my $cnt = $self->xmlify($elem, $lang);
$self->rdf_triple_literal($elem, $id, AWOL_NS.'body', $cnt, RDF_NS.'XMLLiteral');
$self->rdf_triple_literal($elem, $id, AWOL_NS.'type', $elem->getAttribute('type'));
$self->rdf_triple_literal($elem, $id, AWOL_NS.'lang', $lang, XSD_NS.'language') if $lang;
$self->rdf_triple($elem, $id, AWOL_NS.'base', $base) if $base;
}
elsif ($elem->getAttribute('type') =~ m'^text\/'i)
{
my $cnt = $elem->textContent;
$self->rdf_triple_literal($elem, $id, AWOL_NS.'body', $cnt, undef, $lang);
$self->rdf_triple_literal($elem, $id, AWOL_NS.'type', $elem->getAttribute('type'));
$self->rdf_triple_literal($elem, $id, AWOL_NS.'lang', $lang, XSD_NS.'language') if $lang;
$self->rdf_triple($elem, $id, AWOL_NS.'base', $base) if $base;
}
elsif ($elem->hasAttribute('type'))
{
my $cnt = $elem->textContent;
$self->rdf_triple_literal($elem, $id, AWOL_NS.'body', decode_base64($cnt));
$self->rdf_triple_literal($elem, $id, AWOL_NS.'type', $elem->getAttribute('type'));
$self->rdf_triple_literal($elem, $id, AWOL_NS.'lang', $lang, XSD_NS.'language') if $lang;
$self->rdf_triple($elem, $id, AWOL_NS.'base', $base) if $base;
}
return $id;
}
sub consume_person
{
my $self = shift;
my $person = shift;
# Person
my $person_identifier = $self->bnode($person);
$self->rdf_triple($person, $person_identifier, RDF_TYPE, AWOL_NS.'Person');
# name
{
my @elems = $person->getChildrenByTagNameNS(ATOM_NS, 'name');
foreach my $e (@elems)
{
$self->rdf_triple_literal($e, $person_identifier, AWOL_NS.'name', $e->textContent);
}
}
# uri
{
my @elems = $person->getChildrenByTagNameNS(ATOM_NS, 'uri');
foreach my $e (@elems)
{
my $link = $self->uri($e->textContent, $e);
$self->rdf_triple($e, $person_identifier, AWOL_NS.'uri', $link);
}
}
# email
{
my @elems = $person->getChildrenByTagNameNS(ATOM_NS, 'email');
foreach my $e (@elems)
{
$self->rdf_triple($e, $person_identifier, AWOL_NS.'email', 'mailto:'.$e->textContent);
}
}
return $person_identifier;
}
sub consume_generator
{
my $self = shift;
my $elem = shift;
# Person
my $identifier = $self->bnode($elem);
$self->rdf_triple($elem, $identifier, RDF_TYPE, AWOL_NS.'Generator');
# name
{
my $lang = $self->get_node_lang($elem);
$self->rdf_triple_literal($elem, $identifier, AWOL_NS.'name', $elem->textContent, undef, $lang);
}
# uri
if ($elem->hasAttribute('uri'))
{
my $link = $self->uri($elem->getAttribute('uri'), $elem);
$self->rdf_triple($elem, $identifier, AWOL_NS.'uri', $link);
}
# version
if ($elem->hasAttribute('uri'))
{
$self->rdf_triple($elem, $identifier, AWOL_NS.'version', $elem->getAttribute('version'));
}
return $identifier;
}
sub consume_inreplyto
{
my $self = shift;
my $link = shift;
my $id = $self->bnode($link);
$self->rdf_triple($link, $id, RDF_TYPE, AWOL_NS.'Entry');
if ($link->hasAttribute('ref'))
{
$self->rdf_triple_literal($link, $id, AWOL_NS.'id', $link->getAttribute('ref'), XSD_NS.'anyURI');
}
if ($link->hasAttribute('href'))
{
my $href = $self->uri($link->getAttribute('href'), $link);
$self->rdf_triple($link, $id, IANA_NS.'self', $href);
}
# TODO: "type".
if ($link->hasAttribute('source'))
{
my $fid = $self->bnode;
my $href = $self->uri($link->getAttribute('href'), $link);
$self->rdf_triple($link, $id, AWOL_NS.'source', $fid);
$self->rdf_triple($link, $fid, RDF_TYPE, AWOL_NS.'Feed');
$self->rdf_triple($link, $fid, IANA_NS.'self', $href);
}
return $id;
}
sub consume_link
{
my $self = shift;
my $link = shift;
my $subject = shift || undef;
# Link
my $link_identifier = $self->bnode($link);
$self->rdf_triple($link, $link_identifier, RDF_TYPE, AWOL_NS.'Link');
# Destination
my $destination_identifier = $self->bnode;
$self->rdf_triple($link, $destination_identifier, RDF_TYPE, AWOL_NS.'Content');
$self->rdf_triple($link, $link_identifier, AWOL_NS.'to', $destination_identifier);
# rel
{
my $rel = HTTP::Link::Parser::relationship_uri(
$link->hasAttribute('rel') ? $link->getAttribute('rel') : 'alternate');
$self->rdf_triple($link, $link_identifier, AWOL_NS.'rel', $rel);
if ($link->hasAttribute('href') and defined $subject)
{
my $href = $self->uri($link->getAttribute('href'), $link);
$self->rdf_triple($link, $subject, $rel, $href);
}
}
# href
if ($link->hasAttribute('href'))
{
my $href = $self->uri($link->getAttribute('href'), $link);
$self->rdf_triple($link, $destination_identifier, AWOL_NS.'src', $href);
}
# hreflang
if ($link->hasAttribute('hreflang'))
{
my $hreflang = $link->getAttribute('hreflang');
$self->rdf_triple_literal($link, $destination_identifier, AWOL_NS.'lang', $hreflang);
}
# length
if ($link->hasAttribute('length'))
{
my $length = $link->getAttribute('length');
$self->rdf_triple_literal($link, $destination_identifier, AWOL_NS.'length', $length, XSD_NS.'integer');
}
# type
if ($link->hasAttribute('type'))
{
my $type = $link->getAttribute('type');
$self->rdf_triple_literal($link, $destination_identifier, AWOL_NS.'type', $type);
}
# title: TODO - check this uses AWOL properly.
if ($link->hasAttribute('title'))
{
my $lang = $self->get_node_lang($link);
my $title = $link->getAttribute('title');
$self->rdf_triple_literal($link, $link_identifier, AWOL_NS.'title', $title, undef, $lang);
}
# thr:count
if ($link->hasAttributeNS(THR_NS, 'count'))
{
my $count = $link->getAttributeNS(THR_NS, 'count');
$self->rdf_triple_literal($link, $link_identifier, AX_NS.'count', $count, XSD_NS.'integer');
}
# thr:updated
if ($link->hasAttributeNS(THR_NS, 'updated'))
{
my $u = $link->getAttributeNS(THR_NS, 'updated');
$self->rdf_triple_literal($link, $link_identifier, AX_NS.'updated', $u, XSD_NS.'dateTime');
}
return $link_identifier;
}
sub consume_category
{
my $self = shift;
my $elem = shift;
# Link
my $id = $self->bnode($elem);
$self->rdf_triple($elem, $id, RDF_TYPE, AWOL_NS.'Category');
# term
if ($elem->hasAttribute('term'))
{
$self->rdf_triple_literal($elem, $id, AWOL_NS.'term', $elem->getAttribute('term'));
}
# label
if ($elem->hasAttribute('label'))
{
my $lang = $self->get_node_lang($elem);
$self->rdf_triple_literal($elem, $id, AWOL_NS.'label', $elem->getAttribute('label'), undef, $lang);
}
# scheme
if ($elem->hasAttribute('scheme'))
{
my $link = $self->uri($elem->getAttribute('scheme'), $elem);
$self->rdf_triple($elem, $id, AWOL_NS.'scheme', $link);
}
return $id;
}
sub xmlify
# Function only used internally.
{
my $this = shift;
my $dom = shift;
my $lang = shift;
my $rv;
$lang = $this->get_node_lang($dom)
unless $lang;
foreach my $kid ($dom->childNodes)
{
my $fakelang = 0;
if (($kid->nodeType == XML_ELEMENT_NODE) && defined $lang)
{
unless ($kid->hasAttributeNS(XML_XML_NS, 'lang'))
{
$kid->setAttributeNS(XML_XML_NS, 'lang', $lang);
$fakelang++;
}
}
$rv .= $kid->toStringEC14N(1);
if ($fakelang)
{
$kid->removeAttributeNS(XML_XML_NS, 'lang');
}
}
return $rv;
}
sub xmlify_inclusive
# Function only used internally.
{
my $this = shift;
my $dom = shift;
my $lang = shift;
my $rv;
$lang = $this->get_node_lang($dom)
unless $lang;
my $fakelang = 0;
if (($dom->nodeType == XML_ELEMENT_NODE) && defined $lang)
{
unless ($dom->hasAttributeNS(XML_XML_NS, 'lang'))
{
$dom->setAttributeNS(XML_XML_NS, 'lang', $lang);
$fakelang++;
}
}
$rv = $dom->toStringEC14N(1);
if ($fakelang)
{
$dom->removeAttributeNS(XML_XML_NS, 'lang');
}
return $rv;
}
sub get_node_lang
{
my $this = shift;
my $node = shift;
if ($node->hasAttributeNS(XML_XML_NS, 'lang'))
{
return valid_lang($node->getAttributeNS(XML_XML_NS, 'lang')) ?
$node->getAttributeNS(XML_XML_NS, 'lang'):
undef;
}
if ($node != $this->{'DOM'}->documentElement
&& defined $node->parentNode
&& $node->parentNode->nodeType == XML_ELEMENT_NODE)
{
return $this->get_node_lang($node->parentNode);
}
return undef;
}
sub get_node_base
{
my $this = shift;
my $node = shift;
my @base;
while (1)
{
push @base, $node->getAttributeNS(XML_XML_NS, 'base')
if $node->hasAttributeNS(XML_XML_NS, 'base');
$node = $node->parentNode;
last unless blessed($node) && $node->isa('XML::LibXML::Element');
}
my $rv = URI->new($this->uri); # document URI.
while (my $b = pop @base)
{
$rv = URI->new($b)->abs($rv);
}
return $rv->as_string;
}
sub rdf_triple
# Function only used internally.
{
my $this = shift;
my $suppress_triple = 0;
$suppress_triple = $this->{'sub'}->{'pretriple_resource'}($this, @_)
if defined $this->{'sub'}->{'pretriple_resource'};
return if $suppress_triple;
my $element = shift; # A reference to the XML::LibXML element being parsed
my $subject = shift; # Subject URI or bnode
my $predicate = shift; # Predicate URI
my $object = shift; # Resource URI or bnode
my $graph = shift; # Graph URI or bnode (if named graphs feature is enabled)
# First make sure the object node type is ok.
my $to;
if ($object =~ m/^_:(.*)/)
{
$to = RDF::Trine::Node::Blank->new($1);
}
else
{
$to = RDF::Trine::Node::Resource->new($object);
}
# Run the common function
return $this->rdf_triple_common($element, $subject, $predicate, $to, $graph);
}
sub rdf_triple_literal
# Function only used internally.
{
my $this = shift;
my $suppress_triple = 0;
$suppress_triple = $this->{'sub'}->{'pretriple_literal'}($this, @_)
if defined $this->{'sub'}->{'pretriple_literal'};
return if $suppress_triple;
my $element = shift; # A reference to the XML::LibXML element being parsed
my $subject = shift; # Subject URI or bnode
my $predicate = shift; # Predicate URI
my $object = shift; # Resource Literal
my $datatype = shift; # Datatype URI (possibly undef or '')
my $language = shift; # Language (possibly undef or '')
my $graph = shift; # Graph URI or bnode (if named graphs feature is enabled)
# Now we know there's a literal
my $to;
# Work around bad Unicode handling in RDF::Trine.
$object = encode_utf8($object);
if (defined $datatype)
{
if ($datatype eq 'http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral')
{
if ($this->{'options'}->{'use_rtnlx'})
{
eval
{
require RDF::Trine::Node::Literal::XML;
$to = RDF::Trine::Node::Literal::XML->new($element->childNodes);
};
}
if ( $@ || !defined $to)
{
my $orig = $RDF::Trine::Node::Literal::USE_XMLLITERALS;
$RDF::Trine::Node::Literal::USE_XMLLITERALS = 0;
$to = RDF::Trine::Node::Literal->new($object, undef, $datatype);
$RDF::Trine::Node::Literal::USE_XMLLITERALS = $orig;
}
}
else
{
$to = RDF::Trine::Node::Literal->new($object, undef, $datatype);
}
}
else
{
$to = RDF::Trine::Node::Literal->new($object, $language, undef);
}
# Run the common function
$this->rdf_triple_common($element, $subject, $predicate, $to, $graph);
}
sub rdf_triple_common
# Function only used internally.
{
my $this = shift; # A reference to the Parser object
my $element = shift; # A reference to the XML::LibXML element being parsed
my $subject = shift; # Subject URI or bnode
my $predicate = shift; # Predicate URI
my $to = shift; # RDF::Trine::Node Resource URI or bnode
my $graph = shift; # Graph URI or bnode (if named graphs feature is enabled)
# First, make sure subject and predicates are the right kind of nodes
my $tp = RDF::Trine::Node::Resource->new($predicate);
my $ts;
if ($subject =~ m/^_:(.*)/)
{
$ts = RDF::Trine::Node::Blank->new($1);
}
else
{
$ts = RDF::Trine::Node::Resource->new($subject);
}
my $statement;
# If we are configured for it, and graph name can be found, add it.
if (ref($this->{'options'}->{'named_graphs'}) && ($graph))
{
$this->{Graphs}->{$graph}++;
my $tg;
if ($graph =~ m/^_:(.*)/)
{
$tg = RDF::Trine::Node::Blank->new($1);
}
else
{
$tg = RDF::Trine::Node::Resource->new($graph);
}
$statement = RDF::Trine::Statement::Quad->new($ts, $tp, $to, $tg);
}
else
{
$statement = RDF::Trine::Statement->new($ts, $tp, $to);
}
my $suppress_triple = 0;
$suppress_triple = $this->{'sub'}->{'ontriple'}($this, $element, $statement)
if ($this->{'sub'}->{'ontriple'});
return if $suppress_triple;
$this->{RESULTS}->add_statement($statement);
}
sub bnode
# Function only used internally.
{
my $this = shift;
my $element = shift;
if (defined $this->{'bnode_generator'})
{
return $this->{'bnode_generator'}->bnode($element);
}
return sprintf('_:AwolAutoNode%03d', $this->{bnodes}++);
}
sub valid_lang
{
my $value_to_test = shift;
return 1 if (defined $value_to_test) && ($value_to_test eq '');
return 0 unless defined $value_to_test;
# Regex for recognizing RFC 4646 well-formed tags
# http://www.rfc-editor.org/rfc/rfc4646.txt
# http://tools.ietf.org/html/draft-ietf-ltru-4646bis-21
# The structure requires no forward references, so it reverses the order.
# It uses Java/Perl syntax instead of the old ABNF
# The uppercase comments are fragments copied from RFC 4646
# Note: the tool requires that any real "=" or "#" or ";" in the regex be escaped.
my $alpha = '[a-z]'; # ALPHA
my $digit = '[0-9]'; # DIGIT
my $alphanum = '[a-z0-9]'; # ALPHA / DIGIT
my $x = 'x'; # private use singleton
my $singleton = '[a-wyz]'; # other singleton
my $s = '[_-]'; # separator -- lenient parsers will use [_-] -- strict will use [-]
# Now do the components. The structure is slightly different to allow for capturing the right components.
# The notation (?:....) is a non-capturing version of (...): so the "?:" can be deleted if someone doesn't care about capturing.
my $language = '([a-z]{2,8}) | ([a-z]{2,3} $s [a-z]{3})';
# ABNF (2*3ALPHA) / 4ALPHA / 5*8ALPHA --- note: because of how | works in regex, don't use $alpha{2,3} | $alpha{4,8}
# We don't have to have the general case of extlang, because there can be only one extlang (except for zh-min-nan).
# Note: extlang invalid in Unicode language tags
my $script = '[a-z]{4}' ; # 4ALPHA
my $region = '(?: [a-z]{2}|[0-9]{3})' ; # 2ALPHA / 3DIGIT
my $variant = '(?: [a-z0-9]{5,8} | [0-9] [a-z0-9]{3} )' ; # 5*8alphanum / (DIGIT 3alphanum)
my $extension = '(?: [a-wyz] (?: [_-] [a-z0-9]{2,8} )+ )' ; # singleton 1*("-" (2*8alphanum))
my $privateUse = '(?: x (?: [_-] [a-z0-9]{1,8} )+ )' ; # "x" 1*("-" (1*8alphanum))
# Define certain grandfathered codes, since otherwise the regex is pretty useless.
# Since these are limited, this is safe even later changes to the registry --
# the only oddity is that it might change the type of the tag, and thus
# the results from the capturing groups.
# http://www.iana.org/assignments/language-subtag-registry
# Note that these have to be compared case insensitively, requiring (?i) below.
my $grandfathered = '(?:
(en [_-] GB [_-] oed)
| (i [_-] (?: ami | bnn | default | enochian | hak | klingon | lux | mingo | navajo | pwn | tao | tay | tsu ))
| (no [_-] (?: bok | nyn ))
| (sgn [_-] (?: BE [_-] (?: fr | nl) | CH [_-] de ))
| (zh [_-] min [_-] nan)
)';
# old: | zh $s (?: cmn (?: $s Hans | $s Hant )? | gan | min (?: $s nan)? | wuu | yue );
# For well-formedness, we don't need the ones that would otherwise pass.
# For validity, they need to be checked.
# $grandfatheredWellFormed = (?:
# art $s lojban
# | cel $s gaulish
# | zh $s (?: guoyu | hakka | xiang )
# );
# Unicode locales: but we are shifting to a compatible form
# $keyvalue = (?: $alphanum+ \= $alphanum+);
# $keywords = ($keyvalue (?: \; $keyvalue)*);
# We separate items that we want to capture as a single group
my $variantList = $variant . '(?:' . $s . $variant . ')*' ; # special for multiples
my $extensionList = $extension . '(?:' . $s . $extension . ')*' ; # special for multiples
my $langtag = "
($language)
($s ( $script ) )?
($s ( $region ) )?
($s ( $variantList ) )?
($s ( $extensionList ) )?
($s ( $privateUse ) )?
";
# Here is the final breakdown, with capturing groups for each of these components
# The variants, extensions, grandfathered, and private-use may have interior '-'
my $r = ($value_to_test =~
/^(
($langtag)
| ($privateUse)
| ($grandfathered)
)$/xi);
return $r;
}
'A man, a plan, a canal: Panama'; # E, r u true?
__END__
=head1 NAME
XML::Atom::OWL - parse an Atom file into RDF
=head1 SYNOPSIS
use XML::Atom::OWL;
$parser = XML::Atom::OWL->new($xml, $baseuri);
$graph = $parser->graph;
=head1 DESCRIPTION
This has a pretty similar interface to L.
=head2 Constructor
=over 4
=item C<< 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
L object. If a string, the document is parsed
using L, 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 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.
=back
=head2 Public Methods
=over 4
=item C<< 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.
=item C<< dom >>
Returns the parsed XML::LibXML::Document.
=item C<< graph >>
This method will return an RDF::Trine::Model object with all
statements of the full graph.
This method automatically calls C.
=item C<< root_identifier >>
Returns the blank node or URI for the root element of the Atom
document as an RDF::Trine::Node
Calls C automatically.
=item C<< 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. C must
be used I C. C itself returns a reference to the parser
object itself.
=item C<< 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 C 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.
=back
=head1 CALLBACKS
Several callback functions are provided. These may be set using the C function,
which taskes a hashref of keys pointing to coderefs. The keys are named for the event to fire the
callback on.
=head2 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:
=over 4
=item * A reference to the C object
=item * A reference to the C being parsed
=item * Subject URI or bnode (string)
=item * Predicate URI (string)
=item * Object URI or bnode (string)
=item * Graph URI or bnode (string or undef)
=back
The callback should return 1 to tell the parser to skip this triple (not add it to
the graph); return 0 otherwise.
=head2 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:
=over 4
=item * A reference to the C object
=item * A reference to the C being parsed
=item * Subject URI or bnode (string)
=item * Predicate URI (string)
=item * Object literal (string)
=item * Datatype URI (string or undef)
=item * Language (string or undef)
=item * Graph URI or bnode (string or undef)
=back
Beware: sometimes both a datatype I 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.
=head2 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:
=over 4
=item * A reference to the C object
=item * A reference to the C being parsed
=item * An RDF::Trine::Statement object.
=back
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.
=head1 BUGS
Please report any bugs to L.
=head1 SEE ALSO
L, L.
L.
=head1 AUTHOR
Toby Inkster Etobyink@cpan.orgE.
=head1 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.
=head1 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.