XML-Catalog-1.03000755001750001750 012341205651 13341 5ustar00jfearnjfearn000000000000XML-Catalog-1.03/MANIFEST000444001750001750 36312341205651 14611 0ustar00jfearnjfearn000000000000Build.PL Changes lib/XML/Catalog.pm LICENSE Makefile.PL MANIFEST MANIFEST.SKIP META.yml README t/001-load.t t/delegate.cat t/next.cat t/oasis.cat t/test.dtd t/test2.dtd xt/author/perlcritic.t xt/author/pod-coverage.t xt/author/pod.t META.json XML-Catalog-1.03/META.yml000444001750001750 141012341205651 14743 0ustar00jfearnjfearn000000000000--- abstract: 'Resolve public identifiers and remap system identifiers' author: - 'Jeff Fearn ' build_requires: Cwd: 0 LWP::Simple: 0 Test::More: 0 Text::ParseWords: 0 URI::URL: 0 XML::Parser: 0 configure_requires: Module::Build: 0 dynamic_config: 1 generated_by: 'Module::Build version 0.4004, CPAN::Meta::Converter version 2.120921' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: XML-Catalog provides: XML::Catalog: file: lib/XML/Catalog.pm version: 1.03 XML::Catalog::XML: file: lib/XML/Catalog.pm version: 1.02 requires: LWP::Simple: 0 Text::ParseWords: 0 URI::URL: 0 XML::Parser: 0 resources: license: http://dev.perl.org/licenses/ version: 1.03 XML-Catalog-1.03/Makefile.PL000444001750001750 101412341205651 15444 0ustar00jfearnjfearn000000000000# Note: this file was auto-generated by Module::Build::Compat version 0.4004 use ExtUtils::MakeMaker; WriteMakefile ( 'PL_FILES' => {}, 'INSTALLDIRS' => 'site', 'NAME' => 'XML::Catalog', 'EXE_FILES' => [], 'VERSION_FROM' => 'lib/XML/Catalog.pm', 'PREREQ_PM' => { 'Test::More' => 0, 'Text::ParseWords' => 0, 'URI::URL' => 0, 'XML::Parser' => 0, 'LWP::Simple' => 0, 'Cwd' => 0 } ) ; XML-Catalog-1.03/README000444001750001750 230312341205651 14354 0ustar00jfearnjfearn000000000000=head1 NAME XML::Catalog - Resolve public identifiers and remap system identifiers =head1 SYNOPSIS use XML::Catalog; my $catalog=XML::Catalog->new('/xml/catalog.cat'); $catalog->add('http://www.w3.org/xcatalog/mastercat.xml'); my $sysid=$catalog->resolve_public('-//John Cowan//LOC Diacritics'); my $newsysid=$catalog->remap_system('http://www.w3.org'); $parser->setHandlers(ExternEnt=>$catalog->get_handler($parser)); =head1 DESCRIPTION This module implements draft 0.4 of John Cowan's XML Catalog (formerly known as XCatalog) proposal (). Catalogs may be written in either SOCAT or XML syntax (see the proposal for syntax details); XML::Catalog will assume SOCAT syntax if the catalog is not in well-formed XML syntax. This module, as of 1.0.0, also supports Oasis XML catalogs. =head1 AUTHOR Current Author: Jeff Fearn Ejfearn@cpan.orgE. Former Authors: Eric Bohlman (ebohlman@netcom.com) =head1 COPYRIGHT Copyright (c) 1999-2000 Eric Bohlman. All rights reserved. Copyright (c) 2013 Jeff Fearn. All rights reserved. This program is free software; you can use/modify/redistribute it under the same terms as Perl itself. =cut XML-Catalog-1.03/META.json000444001750001750 254712341205651 15127 0ustar00jfearnjfearn000000000000{ "abstract" : "Resolve public identifiers and remap system identifiers", "author" : [ "Jeff Fearn " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.4004, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "XML-Catalog", "prereqs" : { "build" : { "requires" : { "Cwd" : "0", "LWP::Simple" : "0", "Test::More" : "0", "Text::ParseWords" : "0", "URI::URL" : "0", "XML::Parser" : "0" } }, "configure" : { "requires" : { "Module::Build" : "0" } }, "runtime" : { "requires" : { "LWP::Simple" : "0", "Text::ParseWords" : "0", "URI::URL" : "0", "XML::Parser" : "0" } } }, "provides" : { "XML::Catalog" : { "file" : "lib/XML/Catalog.pm", "version" : "1.03" }, "XML::Catalog::XML" : { "file" : "lib/XML/Catalog.pm", "version" : "1.02" } }, "release_status" : "stable", "resources" : { "license" : [ "http://dev.perl.org/licenses/" ] }, "version" : "1.03" } XML-Catalog-1.03/Build.PL000444001750001750 270412341205651 14775 0ustar00jfearnjfearn000000000000use strict; use warnings; use Module::Build; my $class = Module::Build->subclass( class => 'My::Builder', code => q{ sub ACTION_authortest { my ($self) = @_; $self->depends_on('build'); $self->depends_on('distmeta'); $self->test_files( qw< t xt/author > ); $self->recursive_test_files(1); $self->depends_on('test'); return; } sub ACTION_distdir { my ($self) = @_; $self->depends_on('authortest'); return $self->SUPER::ACTION_distdir(); } }, ); my $builder = $class->new( module_name => 'XML::Catalog', license => 'perl', dist_author => 'Jeff Fearn ', dist_version_from => 'lib/XML/Catalog.pm', create_makefile_pl => 'traditional', configure_requires => { 'Module::Build' => 0 }, build_requires => { 'Test::More' => 0, 'XML::Parser' => 0, 'LWP::Simple' => 0, 'URI::URL' => 0, 'Text::ParseWords' => 0, 'Cwd' => 0, }, requires => { 'XML::Parser' => 0, 'LWP::Simple' => 0, 'URI::URL' => 0, 'Text::ParseWords' => 0, }, add_to_cleanup => [ 'XML-Catalog-*', 'tmp', 'blib', '*.bak', 'META.yml', 'META.json' ], script_files => [], ); $builder->create_build_script(); XML-Catalog-1.03/Changes000444001750001750 115412341205651 14772 0ustar00jfearnjfearn000000000000Revision history for Perl extension XML::Catalog. 1.03 Wed May 28 2014 - Add test DTDs to MANIFEST 1.02 Tue May 27 2014 - Fix missing DTDs causing build fail on Windows. - Fix non-portable version declaration. 1.0.1 Mon Oct 28 2013 - Fix test harness failing on some machines. RT #89415 - Add Oasis support for nextCatalog. 1.0.0 Wed Oct 02 2013 - Support Oasis Catalogs. RT #87010 - Fix requires. RT #46047 0.02 Thu Sep 21 09:00:00 2000 - Fixed problem disallowing backslashes in identifiers in SOCAT format - Added get_handler() method 0.01 Fri Jun 11 00:00:00 1999 - original version; created by h2xs 1.18 XML-Catalog-1.03/LICENSE000444001750001750 2070512341205651 14527 0ustar00jfearnjfearn000000000000Artistic License 2.0 Copyright (c) 2000-2006, The Perl Foundation. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble This license establishes the terms under which a given free software Package may be copied, modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains some artistic control over the development of that Package while still keeping the Package available as open source and free software. You are always permitted to make arrangements wholly outside of this license directly with the Copyright Holder of a given Package. If the terms of this license do not permit the full use that you propose to make of the Package, you should contact the Copyright Holder and seek a different licensing arrangement. Definitions "Copyright Holder" means the individual(s) or organization(s) named in the copyright notice for the entire Package. "Contributor" means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures. "You" and "your" means any person who would like to copy, distribute, or modify the Package. "Package" means the collection of files distributed by the Copyright Holder, and derivatives of that collection and/or of those files. A given Package may consist of either the Standard Version, or a Modified Version. "Distribute" means providing a copy of the Package or making it accessible to anyone else, or in the case of a company or organization, to others outside of your company or organization. "Distributor Fee" means any fee that you charge for Distributing this Package or providing support for this Package to another party. It does not mean licensing fees. "Standard Version" refers to the Package if it has not been modified, or has been modified only in ways explicitly requested by the Copyright Holder. "Modified Version" means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder. "Original License" means this Artistic License as Distributed with the Standard Version of the Package, in its current version or as it may be modified by The Perl Foundation in the future. "Source" form means the source code, documentation source, and configuration files for the Package. "Compiled" form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form. Permission for Use and Modification Without Distribution (1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not Distribute the Modified Version. Permissions for Redistribution of the Standard Version (2) You may Distribute verbatim copies of the Source form of the Standard Version of this Package in any medium without restriction, either gratis or for a Distributor Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At your discretion, such verbatim copies may or may not include a Compiled form of the Package. (3) You may apply any bug fixes, portability changes, and other modifications made available from the Copyright Holder. The resulting Package will still be considered the Standard Version, and as such will be subject to the Original License. Distribution of Modified Versions of the Package as Source (4) You may Distribute your Modified Version as Source (either gratis or for a Distributor Fee, and with or without a Compiled form of the Modified Version) provided that you clearly document how it differs from the Standard Version, including, but not limited to, documenting any non-standard features, executables, or modules, and provided that you do at least ONE of the following: (a) make the Modified Version available to the Copyright Holder of the Standard Version, under the Original License, so that the Copyright Holder may include your modifications in the Standard Version. (b) ensure that installation of your Modified Version does not prevent the user installing or running the Standard Version. In addition, the Modified Version must bear a name that is different from the name of the Standard Version. (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under (i) the Original License or (ii) a license that permits the licensee to freely copy, modify and redistribute the Modified Version using the same licensing terms that apply to the copy that the licensee received, and requires that the Source form of the Modified Version, and of any works derived from it, be made freely available in that license fees are prohibited but Distributor Fees are allowed. Distribution of Compiled Forms of the Standard Version or Modified Versions without the Source (5) You may Distribute Compiled forms of the Standard Version without the Source, provided that you include complete instructions on how to get the Source of the Standard Version. Such instructions must be valid at the time of your distribution. If these instructions, at any time while you are carrying out such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If you provide valid instructions or cease distribution within thirty days after you become aware that the instructions are invalid, then you do not forfeit any of your rights under this license. (6) You may Distribute a Modified Version in Compiled form without the Source, provided that you comply with Section 4 with respect to the Source of the Modified Version. Aggregating or Linking the Package (7) You may aggregate the Package (either the Standard Version or Modified Version) with other packages and Distribute the resulting aggregation provided that you do not charge a licensing fee for the Package. Distributor Fees are permitted, and licensing fees for other components in the aggregation are permitted. The terms of this license apply to the use and Distribution of the Standard or Modified Versions as included in the aggregation. (8) You are permitted to link Modified and Standard Versions with other works, to embed the Package in a larger work of your own, or to build stand-alone binary or bytecode versions of applications that include the Package, and Distribute the result without restriction, provided the result does not expose a direct interface to the Package. Items That are Not Considered Part of a Modified Version (9) Works (including, but not limited to, modules and scripts) that merely extend or make use of the Package, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not subject to the terms of this license. General Provisions (10) Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. (11) If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. (12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. (13) This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed. (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. XML-Catalog-1.03/MANIFEST.SKIP000444001750001750 103612341205651 15374 0ustar00jfearnjfearn000000000000# Version control files and dirs. \bRCS\b \bCVS\b ,v$ .svn/ .git/ .gitignore # ExtUtils::MakeMaker generated files and dirs. ^MANIFEST\.(?!SKIP) ^Makefile$ ^blib/ ^blibdirs$ ^PM_to_blib$ ^pm_to_blib$ ^MakeMaker-\d # Module::Build ^Build$ ^_build .bat$ # Coverage ^cover_db # Temp, old, vi and emacs files. ~$ \.old$ ^#.*#$ ^\.# \.swp$ \.bak$ \.tmp$ ^MYMETA.yml$ \bXML-Catalog-v[\d\.\_]+ \.spec$ ^META\.json$ ^MYMETA\.json$ XML-Catalog-1.03/t000755001750001750 012341205651 13604 5ustar00jfearnjfearn000000000000XML-Catalog-1.03/t/next.cat000444001750001750 62212341205651 15370 0ustar00jfearnjfearn000000000000 XML-Catalog-1.03/t/001-load.t000444001750001750 137312341205651 15347 0ustar00jfearnjfearn000000000000use strict; use warnings; use Test::More tests => 5; use Cwd qw(abs_path); BEGIN { use_ok('XML::Catalog'); } diag("Testing XML::Catalog $XML::Catalog::VERSION"); my $catalog = XML::Catalog->new( 'file://' . abs_path('t/oasis.cat') ); isa_ok( $catalog, 'XML::Catalog', 'Check ISA' ); my $pubid = '-//OASIS//TEST DTD//EN'; my $file = $catalog->resolve_public($pubid); is( $file, 'file://' . abs_path('t/test.dtd'), 'Reslove PublicID' ); $pubid = '-//OASIS//TEST 2 DTD//EN'; $file = $catalog->resolve_public($pubid); is( $file, 'file://' . abs_path('t/test.dtd'), 'Reslove deligated PublicID' ); $pubid = '-//OASIS//TEST 3 DTD//EN'; $file = $catalog->resolve_public($pubid); is( $file, 'file://' . abs_path('t/test2.dtd'), 'Reslove nextCatalog' ); XML-Catalog-1.03/t/delegate.cat000444001750001750 62112341205651 16163 0ustar00jfearnjfearn000000000000 XML-Catalog-1.03/t/oasis.cat000444001750001750 127712341205651 15557 0ustar00jfearnjfearn000000000000 XML-Catalog-1.03/t/test2.dtd000444001750001750 6212341205651 15435 0ustar00jfearnjfearn000000000000 ]> XML-Catalog-1.03/t/test.dtd000444001750001750 6112341205651 15352 0ustar00jfearnjfearn000000000000 ]> XML-Catalog-1.03/lib000755001750001750 012341205651 14107 5ustar00jfearnjfearn000000000000XML-Catalog-1.03/lib/XML000755001750001750 012341205651 14547 5ustar00jfearnjfearn000000000000XML-Catalog-1.03/lib/XML/Catalog.pm000444001750001750 3115712341205651 16643 0ustar00jfearnjfearn000000000000package XML::Catalog; use strict; use warnings; use XML::Parser; use LWP::Simple; use URI::URL; use Text::ParseWords; ## no critic our $VERSION = "1.03"; $VERSION = eval $VERSION; ## use critic ##################################################################### # Class variables (private) ##################################################################### # hash of catalog objects indexed by URL (to prevent loops in construction) my %catobjs; # hash of catalog objects visited in current search, indexed by # stringified reference (to prevent loops in search) use vars qw/%visited/; ##################################################################### # Constructor ##################################################################### sub new { my $class = shift; my $url = shift || die "No catalog specified"; my $cat = build( $class, $url ) or return; $cat->add(@_); return $cat; } ##################################################################### # Public methods ##################################################################### sub add { my $self = shift; foreach my $url (@_) { my $cat = build( $self, $url ); $self->add_extend_object( $cat, 'chain' ) if defined $cat; } } sub resolve_public { my ( $self, $pubid ) = @_; %visited = (); # try without delegation my $rm = $self->_resolve_public( $pubid, 0 ); unless ($rm) { # try with delegation %visited = (); $rm = $self->_resolve_public( $pubid, 1 ); } return $self->remap_system($rm) if defined $rm; return; } sub remap_system { my ( $self, $sysid ) = @_; %visited = (); my $rm = $self->_remap_system($sysid); return ( defined($rm) ? $rm : $sysid ); } sub get_handler { my ( $catalog, $parser ) = @_; my ( $t, $orig_handler ) = $parser->setHandlers( ExternEnt => 0 ); return sub { my ( $expat, $base, $sysid, $pubid ) = @_; if ($pubid) { my $t = $catalog->resolve_public($pubid); $sysid = $t if $t; } $sysid = $catalog->remap_system($sysid); $orig_handler->( $expat, $base, $sysid, $pubid ); } } ##################################################################### # Private methods and subs ##################################################################### # create new catalog object sub build { my ( $c, $url ) = @_; return $catobjs{$url} if defined $catobjs{$url}; my $class = ref($c) || $c; my $self = { url => $url, #needed? base => $url, map => {}, remap => {}, delegate => {}, extend => [], chain => [] }; bless( $self, $class ); $catobjs{$url} = $self; $self->parse; return $self; } # add another catalog object as extension to ours sub add_extend_object { my ( $self, $cat, $group ) = @_; foreach my $t ( @{ $self->{$group} } ) { return if $t == $cat; } push @{ $self->{$group} }, $cat; } # translate public identifier with or without delegation, checking for loops sub _resolve_public { my ( $self, $pubid, $allowdeleg ) = @_; return if $visited{$self}; $visited{$self} = 1; if ($allowdeleg) { local %visited; foreach my $deleg ( keys %{ $self->{delegate} } ) { if ( index( $pubid, $deleg ) == 0 ) { my $rm = $self->{delegate}{$deleg}->resolve_public($pubid); return $rm if defined $rm; } } } else { return $self->{map}{$pubid} if defined $self->{map}{$pubid}; } # no local match, try chained and extend entries foreach my $group (qw/chain extend/) { foreach my $cat ( @{ $self->{$group} } ) { my $rm = $cat->_resolve_public( $pubid, $allowdeleg ); return $rm if defined $rm; } } return; } # translate system identifier, checking for loops sub _remap_system { my ( $self, $sysid ) = @_; return if $visited{$self}; return $self->{remap}{$sysid} if defined $self->{remap}{$sysid}; $visited{$self} = 1; foreach my $group (qw/chain extend/) { foreach my $cat ( @{ $self->{$group} } ) { my $rm = $cat->_remap_system($sysid); return $rm if defined $rm; } } return; } sub parse { my $self = shift; my $u = new URI::URL( $self->{url} ); $u->scheme('file') unless $u->scheme(); my $url = $u->as_string(); my $ct = LWP::Simple::get($url); die "Unable to retrieve URL: [$url]" unless defined $ct; $self->parse_SOCAT($ct) unless $self->parse_XML($ct); } sub fix_base { my ( $self, $url ) = @_; my $u = new URI::URL( $url, $self->{base} ); return $u->abs->as_string(); } sub add_map { my ( $self, $pubid, $href ) = @_; $self->{map}{$pubid} = $self->fix_base($href); } sub add_remap { my ( $self, $sysid, $href ) = @_; $self->{remap}{$sysid} = $self->fix_base($href); } sub add_delegate { my ( $self, $pubid, $href ) = @_; my $cat = build( $self, $self->fix_base($href) ); $self->{delegate}{$pubid} = $cat if defined $cat; } sub add_extend { my ( $self, $href ) = @_; $href = $self->fix_base($href); my $cat = build( $self, $href ); $self->add_extend_object( $cat, 'extend' ) if defined $cat; } sub set_base { my ( $self, $href ) = @_; $self->{base} = $self->fix_base($href); } sub parse_SOCAT { my ( $token, $sysid, $pubid, $href ); my ( $self, $ct ) = @_; #backslashes are allowed; change them to forward slashes $ct =~ s#\\#/#g; #strip comments $ct =~ s/((['"]).*\2|.*)--.*?--/$1/g; my @tokens = quotewords( '\s+', 0, $ct ); while ( defined( $token = shift @tokens ) ) { if ( uc $token eq 'PUBLIC' ) { defined( $pubid = shift @tokens ) or return 0; defined( $href = shift @tokens ) or return 0; $self->add_map( $pubid, $href ); } elsif ( uc $token eq 'SYSTEM' ) { defined( $sysid = shift @tokens ) or return 0; defined( $href = shift @tokens ) or return 0; $self->add_remap( $sysid, $href ); } elsif ( uc $token eq 'DELEGATE' ) { defined( $pubid = shift @tokens ) or return 0; defined( $href = shift @tokens ) or return 0; $self->add_delegate( $pubid, $href ); } elsif ( uc $token eq 'CATALOG' ) { defined( $href = shift @tokens ) or return 0; $self->add_extend($href); } elsif ( uc $token eq 'BASE' ) { defined( $href = shift @tokens ) or return 0; $self->set_base($href); } else { next; } } return 1; } sub parse_XML { my ( $self, $ct ) = @_; my $p = new XML::Parser( Style => 'Subs', Pkg => 'XML::Catalog::XML' ); $p->{XMLCatalog} = $self; eval { $p->parse($ct) }; return ( $@ ? 0 : 1 ); } package XML::Catalog::XML; ## no critic our $VERSION = "1.02"; $VERSION = eval $VERSION; ## use critic sub Map { my ( $p, $elem, %attrs ) = @_; my $self = $p->{XMLCatalog}; $self->add_map( $attrs{PublicId}, $attrs{HRef} ); } sub Remap { my ( $p, $elem, %attrs ) = @_; my $self = $p->{XMLCatalog}; $self->add_remap( $attrs{SystemId}, $attrs{HRef} ); } sub Delegate { my ( $p, $elem, %attrs ) = @_; my $self = $p->{XMLCatalog}; $self->add_delegate( $attrs{PublicId}, $attrs{HRef} ); } sub Extend { my ( $p, $elem, %attrs ) = @_; my $self = $p->{XMLCatalog}; $self->add_extend( $attrs{HRef} ); } sub Base { my ( $p, $elem, %attrs ) = @_; my $self = $p->{XMLCatalog}; $self->set_base( $attrs{HRef} ); } # Oasis XML catalog support sub catalog { } sub rewriteURI { my ( $p, $elem, %attrs ) = @_; my $self = $p->{XMLCatalog}; $self->add_delegate( $attrs{uriStartString}, $attrs{rewritePrefix} ); } sub rewriteSystem { my ( $p, $elem, %attrs ) = @_; my $self = $p->{XMLCatalog}; $self->add_delegate( $attrs{systemIdStartString}, $attrs{rewritePrefix} ); } sub public { my ( $p, $elem, %attrs ) = @_; my $self = $p->{XMLCatalog}; $self->add_map( $attrs{publicId}, $attrs{uri} ); } sub delegatePublic { my ( $p, $elem, %attrs ) = @_; my $self = $p->{XMLCatalog}; $self->add_extend( $attrs{catalog} ); } sub delegateSystem { my ( $p, $elem, %attrs ) = @_; my $self = $p->{XMLCatalog}; $self->add_extend( $attrs{catalog} ); } sub delegateURI { my ( $p, $elem, %attrs ) = @_; my $self = $p->{XMLCatalog}; $self->add_extend( $attrs{catalog} ); } sub nextCatalog { my ( $p, $elem, %attrs ) = @_; my $self = $p->{XMLCatalog}; $self->add_extend( $attrs{catalog} ); } sub system { my ( $p, $elem, %attrs ) = @_; my $self = $p->{XMLCatalog}; $self->add_delegate( $attrs{systemId}, $attrs{uri} ); } 1; __END__ =head1 NAME XML::Catalog - Resolve public identifiers and remap system identifiers =head1 SYNOPSIS use XML::Catalog; my $catalog=XML::Catalog->new('/xml/catalog.cat'); $catalog->add('http://www.w3.org/xcatalog/mastercat.xml'); my $sysid=$catalog->resolve_public('-//John Cowan//LOC Diacritics'); my $newsysid=$catalog->remap_system('http://www.w3.org'); $parser->setHandlers(ExternEnt=>$catalog->get_handler($parser)); =head2 Oasis Example $ perl -e 'use XML::Catalog; \ $pubid = q|-//OASIS//DTD DocBook XML V4.5//EN|; \ my $catalog=XML::Catalog->new("/etc/xml/catalog"); \ print $catalog->resolve_public($pubid), "\n";' file:///usr/share/sgml/docbook/xml-dtd-4.5-1.0-51.el6/docbookx.dtd =head1 DESCRIPTION This module implements draft 0.4 of John Cowan's XML Catalog (formerly known as XCatalog) proposal (). Catalogs may be written in either SOCAT or XML syntax (see the proposal for syntax details); XML::Catalog will assume SOCAT syntax if the catalog is not in well-formed XML syntax. This module, as of 1.0.0, also supports Oasis XML catalogs. =head1 CONSTRUCTOR =over 4 =item new(URL [,URL]*) Read the catalog identified by URL and return a catalog object implementing it. If more than one URL is given, chain the additional catalogs as extensions to the catalog (they will be searched before catalogs specified by EXTEND entries). All URLs must be absolute. A URL with no protocol is treated as a filename. =back =head1 METHODS =over 4 =item add(URL [,URL]*) Chain the catalogs identified by the URL(s) to the current catalog. =item resolve_public(PUBID) Translate the public identifier PUBID to a system identifier. Returns undef if the identifier could not be translated. =item remap_system(SYSID) Remap the system identifier SYSID as specified by the catalog. Returns SYSID unchanged if no remapping was found. =item get_handler(PARSER) Returns a coderef to a resolver suitable for use as the ExternEnt handler for an XML::Parser object. The resolver will first attempt to resolve a public identifier if supplied, and then attempt to remap the resulting system identifier (or the original system identifier if no public identifier was supplied). It will then call the original ExternEnt handler associated with the parser object. PARSER is the parser object; it is needed as an argument in order to obtain the original handler. =item add_delegate($pubid, $href) TBD =item add_extend($href) TBD =item add_extend_object($cat, $group ) TBD =item add_map($pubid, $href) TBD =item add_remap($sysid, $href) TBD =item build($url) create new catalog object =item fix_base($url) TBD =item parse TBD =item parse_SOCAT($ct) TBD =item parse_XML($ct) TBD =item set_base($href) TBD =back =head1 BUGS / TODO Searching of chained catalogs is not purely depth-first (EXTEND items in a chained catalog will be searched before EXTEND items in the original catalog. Error checking leaves much to be desired. =head1 AUTHOR Current Author: Jeff Fearn Ejfearn@cpan.orgE. Former Authors: Eric Bohlman Eebohlman@netcom.comE. =head1 COPYRIGHT Copyright (c) 1999-2000 Eric Bohlman. All rights reserved. Copyright (c) 2013 Jeff Fearn. All rights reserved. This program is free software; you can use/modify/redistribute it under the same terms as Perl itself. =cut XML-Catalog-1.03/xt000755001750001750 012341205651 13774 5ustar00jfearnjfearn000000000000XML-Catalog-1.03/xt/author000755001750001750 012341205651 15276 5ustar00jfearnjfearn000000000000XML-Catalog-1.03/xt/author/perlcritic.t000444001750001750 103412341205651 17756 0ustar00jfearnjfearn000000000000#!perl eval "use Test::Perl::Critic"; if ($@) { Test::More::plan( skip_all => "Test::Perl::Critic required for testing PBP compliance" ); } else { Test::Perl::Critic->import( -verbose => 8, -severity => 5, ## This check fails to differentiate between parameters and class variables ## This is not changing a class variable :/ ## $config->param( 'lang', delete( $args->{lang} ) ) if ( $args->{lang} ); -exclude => ['ProhibitAccessOfPrivateData'] ); } Test::Perl::Critic::all_critic_ok(); XML-Catalog-1.03/xt/author/pod-coverage.t000444001750001750 25412341205651 20154 0ustar00jfearnjfearn000000000000#!perl -T use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; all_pod_coverage_ok(); XML-Catalog-1.03/xt/author/pod.t000444001750001750 21412341205651 16357 0ustar00jfearnjfearn000000000000#!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok();