XML-NamespaceSupport-1.12000755001750001750 013067267257 16224 5ustar00perigrinperigrin000000000000README100644001750001750 103713067267257 17166 0ustar00perigrinperigrin000000000000XML-NamespaceSupport-1.12 XML::NamespaceSupport This module offers a simple way to process namespaced XML names (unames) from within any application that may need them. It also helps maintain a prefix to namespace URI map, and provides a number of basic checks. The model for this module is SAX2's NamespaceSupport class, readable at http://www.saxproject.org/namespaces.html It adds a few perlisations where we thought it appropriate, and supports the Namespaces in XML 1.1 specification. -- Robin Berjon Changes100644001750001750 565413067267257 17612 0ustar00perigrinperigrin000000000000XML-NamespaceSupport-1.12 Revision history for XML-NamespaceSupport 1.12 2017-03-30 15:46:34-05:00 America/Chicago - Dzilify and re-release 1.10 2009-06-12 - Release real version since CPAN testers gave us a pass (perigrin) 1.09_90 2009-05-28 - Re-bundle with modern testing and Module::Install (perigrin) 1.09 fri 20050513 00:50 - add support (on by default) for the Namespaces in XML 1.1 spec. 1.08 thu 20020822 14:01 - "fix" it to follow the latest XML NS Errata barfing around 1.07 mon 20020527 14:41 - added undeclare_prefix() thanks to Christian Glahn. 1.06 tue 20020514 17:36 - CPAN problem, had to change the version 1.05 fri 20020404 14:00 - added a number of rather good speedups by converting a lot of the code to use arrays instead of hashes. More of the same kind of tuning is expected for the next version. - fixed another bug, again thanks to Grant McLean, due to which declarePrefix() was not functionning according to the spec (it failed to set a random prefix when the prefix was undef). 1.04 fri 20020125 18:34:39 - fixed a very nasty bug reported by Grant McLean. getPrefix() had an immediate return() inside of a while() that iterated over the declared prefixes using each(). Because of that, calling getPrefix() twice in a row would return nothing the next time because the each() internal iterator wasn't reset. Sometimes Perl bites. 1.03 wed 20020123 19:04:19 - a few warnings were confusing people when they wrongly used undef prefixes. The warning has now been made explicit (as it reveals a problem in the calling code). - turned the namespace constants into variables so that it is easier to use them from outside. 1.02 thu 20011129 19:04:38 - misc fixes in the docs - removed the uri_unknown_prefix option as it wasn't what Matt thought it patched (it did seem strange, but then I've seen stranger feature requests ;-) - added the automatic generation of prefixes when they are set to undef. Be warned that it's a potentially dangerous behaviour if you mix undef and the empty string. However this is compliant with SAX2 and PerlDOM. 0.02 - 1.00 wed 20011128 23:37:41 - misc fixes in the docs and parts of the code - added the uri_unknown_prefix option (Matt Sergeant) 0.02 thu 20010920 16:39:31 - integrated a number of fixes and suggestions from the perl-xml list (thanks to in no particular order and with possible accidental omissions: Eric Bohlman, Ken MacLeod, Bart Schuller, Andrew Pimlott, Tim Bray, Adam Turoff, and Duncan Cameron). - integrated Duncan Cameron's version: . changed name to XML::NamespaceSupport to mirror the SAX2 spec . added all the interfaces corresponding to that class . added a few tests - fixed a few bugs - added aliases for people that prefer Java-style names - updated docs - included and updated tests that were unreleased in the first version 0.01 sun 20010916 21:20:20 - original version LICENSE100644001750001750 4365513067267257 17347 0ustar00perigrinperigrin000000000000XML-NamespaceSupport-1.12This software is copyright (c) 2015 by Robin Berjon. 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) 2015 by Robin Berjon. 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) 2015 by Robin Berjon. 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 dist.ini100644001750001750 617213067267257 17757 0ustar00perigrinperigrin000000000000XML-NamespaceSupport-1.12name = XML-NamespaceSupport author = Robin Berjon author = Chris Prather license = Perl_5 copyright_holder = Robin Berjon copyright_year = 2015 ; version provider [Git::NextVersion] ; get version from last release tag version_regexp = ^(\d+\.\d+)$ ; collect contributors list [Git::Contributors] ; choose files to include [Git::GatherDir] ; everything from git ls-files exclude_filename = cpanfile ; skip this generated file [PruneCruft] ; default stuff to skip [ManifestSkip] ; if -f MANIFEST.SKIP, skip those, too ; file modifications [OurPkgVersion] ; add $VERSION = ... to all files [InsertCopyright] ; add copyright at "# COPYRIGHT" [PodWeaver] ; generate Pod ; generated files [License] ; boilerplate license ; metadata [AutoPrereqs] ; find prereqs from code skip = ^t::lib [Authority] authority = cpan:PERIGRIN do_munging = 0 [MinimumPerl] ; determine minimum perl version [MetaNoIndex] ; sets 'no_index' in META directory = t directory = xt directory = examples directory = corpus package = DB ; just in case [GithubMeta] ; set META resources remote = origin remote = github issues = 1 [MetaProvides::Package] ; add 'provides' to META files meta_noindex = 1 ; respect prior no_index directives [Prereqs::AuthorDeps] ; add authordeps as develop/requires [MetaYAML] ; generate META.yml (v1.4) [MetaJSON] ; generate META.json (v2) [CPANFile] ; generate cpanfile ; build system [ExecDir] ; include 'bin/*' as executables [ShareDir] ; include 'share/' for File::ShareDir [MakeMaker] ; create Makefile.PL eumm_version = 6.17 default_jobs = 9 ; manifest (after all generated files) [Manifest] ; create MANIFEST ; copy cpanfile back to repo dis [CopyFilesFromBuild] copy = cpanfile ; before release [PromptIfStale] ; check if our build tools are out of date module = Dist::Zilla check_all_plugins = 1 [Git::CheckFor::CorrectBranch] ; ensure on master branch [Git::Check] ; ensure all files checked in allow_dirty = dist.ini allow_dirty = Changes allow_dirty = cpanfile [CheckMetaResources] ; ensure META has 'resources' data [CheckPrereqsIndexed] ; ensure prereqs are on CPAN [CheckChangesHasContent] ; ensure Changes has been updated [RunExtraTests] ; ensure xt/ tests pass default_jobs = 9 [TestRelease] ; ensure t/ tests pass [ConfirmRelease] ; prompt before uploading ; releaser [UploadToCPAN] ; uploads to CPAN ; after release [Git::Commit / Commit_Dirty_Files] ; commit Changes (as released) [Git::Tag] ; tag repo with custom tag tag_format = %v ; NextRelease acts *during* pre-release to write $VERSION and ; timestamp to Changes and *after* release to add a new {{$NEXT}} ; section, so to act at the right time after release, it must actually ; come after Commit_Dirty_Files but before Commit_Changes in the ; dist.ini. It will still act during pre-release as usual [NextRelease] [Git::Commit / Commit_Changes] ; commit Changes (for new dev) [Git::Push] ; push repo to remote push_to = origin META.yml100644001750001750 235213067267257 17560 0ustar00perigrinperigrin000000000000XML-NamespaceSupport-1.12--- abstract: 'A simple generic namespace processor' author: - 'Robin Berjon ' - 'Chris Prather ' build_requires: Test::More: '0' perl: '5.006' configure_requires: ExtUtils::MakeMaker: '6.17' perl: '5.006' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.009, CPAN::Meta::Converter version 2.150005' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: XML-NamespaceSupport no_index: directory: - corpus - examples - t - xt package: - DB provides: XML::NamespaceSupport: file: lib/XML/NamespaceSupport.pm version: '1.12' requires: constant: '0' perl: '5.006' strict: '0' vars: '0' warnings: '0' resources: bugtracker: https://github.com/perigrin/xml-namespacesupport/issues homepage: https://github.com/perigrin/xml-namespacesupport repository: https://github.com/perigrin/xml-namespacesupport.git version: '1.12' x_authority: cpan:PERIGRIN x_contributors: - 'Chris Prather ' - 'David Steinbrunner ' - 'Paul Cochrane ' - 'Paulo Custodio ' x_serialization_backend: 'YAML::Tiny version 1.70' cpanfile100644001750001750 475313067267257 20022 0ustar00perigrinperigrin000000000000XML-NamespaceSupport-1.12requires "constant" => "0"; requires "perl" => "5.006"; requires "strict" => "0"; requires "vars" => "0"; requires "warnings" => "0"; on 'test' => sub { requires "Test::More" => "0"; requires "perl" => "5.006"; }; on 'configure' => sub { requires "ExtUtils::MakeMaker" => "6.17"; requires "perl" => "5.006"; }; on 'develop' => sub { requires "Dist::Zilla" => "5"; requires "Dist::Zilla::Plugin::Authority" => "0"; requires "Dist::Zilla::Plugin::AutoPrereqs" => "0"; requires "Dist::Zilla::Plugin::CPANFile" => "0"; requires "Dist::Zilla::Plugin::CheckChangesHasContent" => "0"; requires "Dist::Zilla::Plugin::CheckMetaResources" => "0"; requires "Dist::Zilla::Plugin::CheckPrereqsIndexed" => "0"; requires "Dist::Zilla::Plugin::ConfirmRelease" => "0"; requires "Dist::Zilla::Plugin::CopyFilesFromBuild" => "0"; requires "Dist::Zilla::Plugin::ExecDir" => "0"; requires "Dist::Zilla::Plugin::Git::Check" => "0"; requires "Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch" => "0"; requires "Dist::Zilla::Plugin::Git::Commit" => "0"; requires "Dist::Zilla::Plugin::Git::Contributors" => "0"; requires "Dist::Zilla::Plugin::Git::GatherDir" => "0"; requires "Dist::Zilla::Plugin::Git::NextVersion" => "0"; requires "Dist::Zilla::Plugin::Git::Push" => "0"; requires "Dist::Zilla::Plugin::Git::Tag" => "0"; requires "Dist::Zilla::Plugin::GithubMeta" => "0"; requires "Dist::Zilla::Plugin::InsertCopyright" => "0"; requires "Dist::Zilla::Plugin::License" => "0"; requires "Dist::Zilla::Plugin::MakeMaker" => "0"; requires "Dist::Zilla::Plugin::Manifest" => "0"; requires "Dist::Zilla::Plugin::ManifestSkip" => "0"; requires "Dist::Zilla::Plugin::MetaJSON" => "0"; requires "Dist::Zilla::Plugin::MetaNoIndex" => "0"; requires "Dist::Zilla::Plugin::MetaProvides::Package" => "0"; requires "Dist::Zilla::Plugin::MetaYAML" => "0"; requires "Dist::Zilla::Plugin::MinimumPerl" => "0"; requires "Dist::Zilla::Plugin::NextRelease" => "0"; requires "Dist::Zilla::Plugin::OurPkgVersion" => "0"; requires "Dist::Zilla::Plugin::PodWeaver" => "0"; requires "Dist::Zilla::Plugin::Prereqs::AuthorDeps" => "0"; requires "Dist::Zilla::Plugin::PromptIfStale" => "0"; requires "Dist::Zilla::Plugin::PruneCruft" => "0"; requires "Dist::Zilla::Plugin::RunExtraTests" => "0"; requires "Dist::Zilla::Plugin::ShareDir" => "0"; requires "Dist::Zilla::Plugin::TestRelease" => "0"; requires "Dist::Zilla::Plugin::UploadToCPAN" => "0"; requires "Software::License::Perl_5" => "0"; }; MANIFEST100644001750001750 32413067267257 17415 0ustar00perigrinperigrin000000000000XML-NamespaceSupport-1.12# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.009. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README cpanfile dist.ini lib/XML/NamespaceSupport.pm t/00base.t weaver.ini META.json100644001750001750 1031513067267257 17746 0ustar00perigrinperigrin000000000000XML-NamespaceSupport-1.12{ "abstract" : "A simple generic namespace processor", "author" : [ "Robin Berjon ", "Chris Prather " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.009, CPAN::Meta::Converter version 2.150005", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "XML-NamespaceSupport", "no_index" : { "directory" : [ "corpus", "examples", "t", "xt" ], "package" : [ "DB" ] }, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.17", "perl" : "5.006" } }, "develop" : { "requires" : { "Dist::Zilla" : "5", "Dist::Zilla::Plugin::Authority" : "0", "Dist::Zilla::Plugin::AutoPrereqs" : "0", "Dist::Zilla::Plugin::CPANFile" : "0", "Dist::Zilla::Plugin::CheckChangesHasContent" : "0", "Dist::Zilla::Plugin::CheckMetaResources" : "0", "Dist::Zilla::Plugin::CheckPrereqsIndexed" : "0", "Dist::Zilla::Plugin::ConfirmRelease" : "0", "Dist::Zilla::Plugin::CopyFilesFromBuild" : "0", "Dist::Zilla::Plugin::ExecDir" : "0", "Dist::Zilla::Plugin::Git::Check" : "0", "Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch" : "0", "Dist::Zilla::Plugin::Git::Commit" : "0", "Dist::Zilla::Plugin::Git::Contributors" : "0", "Dist::Zilla::Plugin::Git::GatherDir" : "0", "Dist::Zilla::Plugin::Git::NextVersion" : "0", "Dist::Zilla::Plugin::Git::Push" : "0", "Dist::Zilla::Plugin::Git::Tag" : "0", "Dist::Zilla::Plugin::GithubMeta" : "0", "Dist::Zilla::Plugin::InsertCopyright" : "0", "Dist::Zilla::Plugin::License" : "0", "Dist::Zilla::Plugin::MakeMaker" : "0", "Dist::Zilla::Plugin::Manifest" : "0", "Dist::Zilla::Plugin::ManifestSkip" : "0", "Dist::Zilla::Plugin::MetaJSON" : "0", "Dist::Zilla::Plugin::MetaNoIndex" : "0", "Dist::Zilla::Plugin::MetaProvides::Package" : "0", "Dist::Zilla::Plugin::MetaYAML" : "0", "Dist::Zilla::Plugin::MinimumPerl" : "0", "Dist::Zilla::Plugin::NextRelease" : "0", "Dist::Zilla::Plugin::OurPkgVersion" : "0", "Dist::Zilla::Plugin::PodWeaver" : "0", "Dist::Zilla::Plugin::Prereqs::AuthorDeps" : "0", "Dist::Zilla::Plugin::PromptIfStale" : "0", "Dist::Zilla::Plugin::PruneCruft" : "0", "Dist::Zilla::Plugin::RunExtraTests" : "0", "Dist::Zilla::Plugin::ShareDir" : "0", "Dist::Zilla::Plugin::TestRelease" : "0", "Dist::Zilla::Plugin::UploadToCPAN" : "0", "Software::License::Perl_5" : "0" } }, "runtime" : { "requires" : { "constant" : "0", "perl" : "5.006", "strict" : "0", "vars" : "0", "warnings" : "0" } }, "test" : { "requires" : { "Test::More" : "0", "perl" : "5.006" } } }, "provides" : { "XML::NamespaceSupport" : { "file" : "lib/XML/NamespaceSupport.pm", "version" : "1.12" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/perigrin/xml-namespacesupport/issues" }, "homepage" : "https://github.com/perigrin/xml-namespacesupport", "repository" : { "type" : "git", "url" : "https://github.com/perigrin/xml-namespacesupport.git", "web" : "https://github.com/perigrin/xml-namespacesupport" } }, "version" : "1.12", "x_authority" : "cpan:PERIGRIN", "x_contributors" : [ "Chris Prather ", "David Steinbrunner ", "Paul Cochrane ", "Paulo Custodio " ], "x_serialization_backend" : "Cpanel::JSON::XS version 3.0231" } t000755001750001750 013067267257 16410 5ustar00perigrinperigrin000000000000XML-NamespaceSupport-1.1200base.t100644001750001750 1103613067267257 20030 0ustar00perigrinperigrin000000000000XML-NamespaceSupport-1.12/tuse strict; use Test::More tests => 49; use XML::NamespaceSupport; use constant FATALS => 0; # root object use constant NSMAP => 1; use constant UNKNOWN_PREF => 2; use constant AUTO_PREFIX => 3; use constant XMLNS_11 => 4; use constant DEFAULT => 0; # maps use constant PREFIX_MAP => 1; use constant DECLARATIONS => 2; # initial prefixes and URIs my $ns = XML::NamespaceSupport->new( { xmlns => 1, fatal_errors => 0, auto_prefix => 1 } ); ok( @{ $ns->[NSMAP] } == 1 ); ok( join( ' ', sort $ns->get_prefixes ), 'xml xmlns' ); ok( not defined $ns->get_uri('') ); ok( $ns->get_uri('xmlns'), 'http://www.w3.org/2000/xmlns/' ); # new context $ns->push_context; ok( @{ $ns->[NSMAP] } == 2 ); is( join( ' ', sort $ns->get_declared_prefixes ), '', 'no declared_prefixes' ); ok( join( ' ', sort $ns->get_prefixes ), 'xml xmlns' ); # new prefixes are added ok( $ns->declare_prefix( '', 'http://www.ibm.com' ) ); ok( $ns->declare_prefix( 'icl', 'http://www.icl.com' ) ); ok( $ns->declare_prefix( 'icl2', 'http://www.icl.com' ) ); ok( not $ns->declare_prefix( 'xml123', 'www.xml.com' ) ); ok( join( ' ', $ns->get_declared_prefixes ), ' icl icl2' ); ok( join( ' ', sort $ns->get_prefixes ), 'icl icl2 xml xmlns' ); ok( join( ' ', sort $ns->get_prefixes('http://www.icl.com') ), 'icl icl2' ); ok( $ns->get_prefix('http://www.icl.com') =~ /^icl/ ); ok( $ns->get_uri('icl2'), 'http://www.icl.com' ); ok( join( ' ', $ns->process_name('icl:el1') ), 'http://www.icl.com el1 icl:el1' ); ok( join( ' ', $ns->process_element_name('icl:el1') ), 'http://www.icl.com icl el1' ); ok( not $ns->process_element_name('aaa:el1') ); ok( join( ' ', map { $_ || 'undef' } $ns->process_element_name('el1') ), 'http://www.ibm.com undef el1' ); ok( join( ' ', $ns->process_element_name('xml:el1') ), 'http://www.w3.org/XML/1998/namespace xml el1' ); ok( not $ns->process_name('aa:bb:cc') ); ok( join( ' ', $ns->process_attribute_name('icl:att1') ), 'http://www.icl.com icl att1' ); ok( not $ns->process_attribute_name('aaa:att1') ); ok( join( ' ', map { $_ || 'undef' } $ns->process_attribute_name('att1') ), 'undef undef att1' ); ok( join( ' ', $ns->process_attribute_name('xml:att1') ), 'http://www.w3.org/XML/1998/namespace xml att1' ); # new context and undeclaring default ns $ns->push_context; ok( @{ $ns->[NSMAP] } == 3 ); ok( $ns->declare_prefix( '', '' ) ); $ns->[XMLNS_11] = 0; eval { $ns->declare_prefix( 'icl', '' ) }; ok($@); $ns->[XMLNS_11] = 1; ok( $ns->declare_prefix( 'iclX', '' ) ); ok( join( ' ', map { $_ || 'undef' } $ns->process_element_name('') ), 'undef undef undef' ); ok( join( ' ', sort $ns->get_prefixes('http://www.icl.com') ), 'icl icl2' ); # new prefix and default ns $ns->push_context; $ns->declare_prefix( 'perl', 'http://www.perl.com' ); $ns->declare_prefix( '', 'http://www.java.com' ); $ns->[FATALS] = 1; # go to strict mode ok( join( ' ', $ns->get_declared_prefixes ), 'perl ' ); ok( join( ' ', $ns->process_element_name('icl:el1') ), 'http://www.icl.com icl el1' ); eval { $ns->process_element_name('aaa:el1') }; ok($@); ok( join( ' ', map { $_ || 'undef' } $ns->process_element_name('el1') ), 'http://www.java.com undef el1' ); ok( join( ' ', $ns->process_element_name('perl:el1') ), 'http://www.perl.com perl el1' ); ok( join( ' ', $ns->process_attribute_name('icl:att1') ), 'http://www.icl.com icl att1' ); eval { $ns->process_attribute_name('aaa:att1') }; ok($@); ok( join( ' ', map { $_ || 'undef' } $ns->process_attribute_name('att1') ), 'undef undef att1' ); ok( join( ' ', $ns->process_attribute_name('perl:att1') ), 'http://www.perl.com perl att1' ); # previous prefixes have gone $ns->pop_context; $ns->pop_context; ok( @{ $ns->[NSMAP] } == 2 ); ok( join( ' ', sort $ns->get_prefixes('http://www.icl.com') ), 'icl icl2' ); # only initial prefixes remain $ns->pop_context; ok( @{ $ns->[NSMAP] } == 1 ); ok( join( ' ', sort $ns->get_prefixes ), 'xml xmlns' ); # reset object for re-use $ns->push_context; $ns->declare_prefix( 'perl', 'http://www.perl.com' ); $ns->declare_prefix( '', 'http://www.java.com' ); $ns->reset; ok( @{ $ns->[NSMAP] } == 1 ); ok( join( ' ', sort $ns->get_prefixes ), 'xml xmlns' ); # undef prefix test $ns->push_context; $ns->declare_prefix( undef, 'http://berjon.com' ); ok( defined $ns->get_prefix('http://berjon.com') ); # get_declared_prefixes without context { my $ns = XML::NamespaceSupport->new; eval { $ns->get_declared_prefixes }; ok( $@ =~ /At least one context/, "get_declared_prefixes raises error without context on stack" ); } weaver.ini100644001750001750 3313067267257 20233 0ustar00perigrinperigrin000000000000XML-NamespaceSupport-1.12[@Default] [Contributors] Makefile.PL100644001750001750 226513067267257 20264 0ustar00perigrinperigrin000000000000XML-NamespaceSupport-1.12# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.009. use strict; use warnings; use 5.006; use ExtUtils::MakeMaker 6.17; my %WriteMakefileArgs = ( "ABSTRACT" => "A simple generic namespace processor", "AUTHOR" => "Robin Berjon , Chris Prather ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.17" }, "DISTNAME" => "XML-NamespaceSupport", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.006", "NAME" => "XML::NamespaceSupport", "PREREQ_PM" => { "constant" => 0, "strict" => 0, "vars" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "Test::More" => 0 }, "VERSION" => "1.12", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Test::More" => 0, "constant" => 0, "strict" => 0, "vars" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); XML000755001750001750 013067267257 17353 5ustar00perigrinperigrin000000000000XML-NamespaceSupport-1.12/libNamespaceSupport.pm100644001750001750 4675213067267257 23400 0ustar00perigrinperigrin000000000000XML-NamespaceSupport-1.12/lib/XMLpackage XML::NamespaceSupport; use strict; our $VERSION = '1.12'; # VERSION # ABSTRACT: A simple generic namespace processor use constant FATALS => 0; # root object use constant NSMAP => 1; use constant UNKNOWN_PREF => 2; use constant AUTO_PREFIX => 3; use constant XMLNS_11 => 4; use constant DEFAULT => 0; # maps use constant PREFIX_MAP => 1; use constant DECLARATIONS => 2; use vars qw($NS_XMLNS $NS_XML); $NS_XMLNS = 'http://www.w3.org/2000/xmlns/'; $NS_XML = 'http://www.w3.org/XML/1998/namespace'; # add the ns stuff that baud wants based on Java's xml-writer #-------------------------------------------------------------------# # constructor #-------------------------------------------------------------------# sub new { my $class = ref($_[0]) ? ref(shift) : shift; my $options = shift; my $self = [ 1, # FATALS [[ # NSMAP undef, # DEFAULT { xml => $NS_XML }, # PREFIX_MAP undef, # DECLARATIONS ]], 'aaa', # UNKNOWN_PREF 0, # AUTO_PREFIX 1, # XML_11 ]; $self->[NSMAP]->[0]->[PREFIX_MAP]->{xmlns} = $NS_XMLNS if $options->{xmlns}; $self->[FATALS] = $options->{fatal_errors} if defined $options->{fatal_errors}; $self->[AUTO_PREFIX] = $options->{auto_prefix} if defined $options->{auto_prefix}; $self->[XMLNS_11] = $options->{xmlns_11} if defined $options->{xmlns_11}; return bless $self, $class; } #-------------------------------------------------------------------# # reset() - return to the original state (for reuse) #-------------------------------------------------------------------# sub reset { my $self = shift; $#{$self->[NSMAP]} = 0; } #-------------------------------------------------------------------# # push_context() - add a new empty context to the stack #-------------------------------------------------------------------# sub push_context { my $self = shift; push @{$self->[NSMAP]}, [ $self->[NSMAP]->[-1]->[DEFAULT], { %{$self->[NSMAP]->[-1]->[PREFIX_MAP]} }, [], ]; } #-------------------------------------------------------------------# # pop_context() - remove the topmost context from the stack #-------------------------------------------------------------------# sub pop_context { my $self = shift; die 'Trying to pop context without push context' unless @{$self->[NSMAP]} > 1; pop @{$self->[NSMAP]}; } #-------------------------------------------------------------------# # declare_prefix() - declare a prefix in the current scope #-------------------------------------------------------------------# sub declare_prefix { my $self = shift; my $prefix = shift; my $value = shift; warn <<' EOWARN' unless defined $prefix or $self->[AUTO_PREFIX]; Prefix was undefined. If you wish to set the default namespace, use the empty string ''. If you wish to autogenerate prefixes, set the auto_prefix option to a true value. EOWARN no warnings 'uninitialized'; if ($prefix eq 'xml' and $value ne $NS_XML) { die "The xml prefix can only be bound to the $NS_XML namespace." } elsif ($value eq $NS_XML and $prefix ne 'xml') { die "the $NS_XML namespace can only be bound to the xml prefix."; } elsif ($value eq $NS_XML and $prefix eq 'xml') { return 1; } return 0 if index(lc($prefix), 'xml') == 0; use warnings 'uninitialized'; if (defined $prefix and $prefix eq '') { $self->[NSMAP]->[-1]->[DEFAULT] = $value; } else { die "Cannot declare prefix $prefix" if $value eq '' and not $self->[XMLNS_11]; if (not defined $prefix and $self->[AUTO_PREFIX]) { while (1) { $prefix = $self->[UNKNOWN_PREF]++; last if not exists $self->[NSMAP]->[-1]->[PREFIX_MAP]->{$prefix}; } } elsif (not defined $prefix and not $self->[AUTO_PREFIX]) { return 0; } $self->[NSMAP]->[-1]->[PREFIX_MAP]->{$prefix} = $value; } push @{$self->[NSMAP]->[-1]->[DECLARATIONS]}, $prefix; return 1; } #-------------------------------------------------------------------# # declare_prefixes() - declare several prefixes in the current scope #-------------------------------------------------------------------# sub declare_prefixes { my $self = shift; my %prefixes = @_; while (my ($k,$v) = each %prefixes) { $self->declare_prefix($k,$v); } } #-------------------------------------------------------------------# # undeclare_prefix #-------------------------------------------------------------------# sub undeclare_prefix { my $self = shift; my $prefix = shift; return if not defined($prefix); return unless exists $self->[NSMAP]->[-1]->[PREFIX_MAP]->{$prefix}; my ( $tfix ) = grep { $_ eq $prefix } @{$self->[NSMAP]->[-1]->[DECLARATIONS]}; if ( not defined $tfix ) { die "prefix $prefix not declared in this context\n"; } @{$self->[NSMAP]->[-1]->[DECLARATIONS]} = grep { $_ ne $prefix } @{$self->[NSMAP]->[-1]->[DECLARATIONS]}; delete $self->[NSMAP]->[-1]->[PREFIX_MAP]->{$prefix}; } #-------------------------------------------------------------------# # get_prefix() - get a (random) prefix for a given URI #-------------------------------------------------------------------# sub get_prefix { my $self = shift; my $uri = shift; # we have to iterate over the whole hash here because if we don't # the iterator isn't reset and the next pass will fail my $pref; while (my ($k, $v) = each %{$self->[NSMAP]->[-1]->[PREFIX_MAP]}) { $pref = $k if $v eq $uri; } return $pref; } #-------------------------------------------------------------------# # get_prefixes() - get all the prefixes for a given URI #-------------------------------------------------------------------# sub get_prefixes { my $self = shift; my $uri = shift; return keys %{$self->[NSMAP]->[-1]->[PREFIX_MAP]} unless defined $uri; return grep { $self->[NSMAP]->[-1]->[PREFIX_MAP]->{$_} eq $uri } keys %{$self->[NSMAP]->[-1]->[PREFIX_MAP]}; } #-------------------------------------------------------------------# # get_declared_prefixes() - get all prefixes declared in the last context #-------------------------------------------------------------------# sub get_declared_prefixes { my $declarations = $_[0]->[NSMAP]->[-1]->[DECLARATIONS]; die "At least one context must be pushed onto stack with push_context()\n", "before calling get_declared_prefixes()" if not defined $declarations; return @{$_[0]->[NSMAP]->[-1]->[DECLARATIONS]}; } #-------------------------------------------------------------------# # get_uri() - get a URI given a prefix #-------------------------------------------------------------------# sub get_uri { my $self = shift; my $prefix = shift; warn "Prefix must not be undef in get_uri(). The emtpy prefix must be ''" unless defined $prefix; return $self->[NSMAP]->[-1]->[DEFAULT] if $prefix eq ''; return $self->[NSMAP]->[-1]->[PREFIX_MAP]->{$prefix} if exists $self->[NSMAP]->[-1]->[PREFIX_MAP]->{$prefix}; return undef; } #-------------------------------------------------------------------# # process_name() - provide details on a name #-------------------------------------------------------------------# sub process_name { my $self = shift; my $qname = shift; my $aflag = shift; if ($self->[FATALS]) { return( ($self->_get_ns_details($qname, $aflag))[0,2], $qname ); } else { eval { return( ($self->_get_ns_details($qname, $aflag))[0,2], $qname ); } } } #-------------------------------------------------------------------# # process_element_name() - provide details on a element's name #-------------------------------------------------------------------# sub process_element_name { my $self = shift; my $qname = shift; if ($self->[FATALS]) { return $self->_get_ns_details($qname, 0); } else { eval { return $self->_get_ns_details($qname, 0); } } } #-------------------------------------------------------------------# # process_attribute_name() - provide details on a attribute's name #-------------------------------------------------------------------# sub process_attribute_name { my $self = shift; my $qname = shift; if ($self->[FATALS]) { return $self->_get_ns_details($qname, 1); } else { eval { return $self->_get_ns_details($qname, 1); } } } #-------------------------------------------------------------------# # ($ns, $prefix, $lname) = $self->_get_ns_details($qname, $f_attr) # returns ns, prefix, and lname for a given attribute name # >> the $f_attr flag, if set to one, will work for an attribute #-------------------------------------------------------------------# sub _get_ns_details { my $self = shift; my $qname = shift; my $aflag = shift; my ($ns, $prefix, $lname); (my ($tmp_prefix, $tmp_lname) = split /:/, $qname, 3) < 3 or die "Invalid QName: $qname"; # no prefix my $cur_map = $self->[NSMAP]->[-1]; if (not defined($tmp_lname)) { $prefix = undef; $lname = $qname; # attr don't have a default namespace $ns = ($aflag) ? undef : $cur_map->[DEFAULT]; } # prefix else { if (exists $cur_map->[PREFIX_MAP]->{$tmp_prefix}) { $prefix = $tmp_prefix; $lname = $tmp_lname; $ns = $cur_map->[PREFIX_MAP]->{$prefix} } else { # no ns -> lname == name, all rest undef die "Undeclared prefix: $tmp_prefix"; } } return ($ns, $prefix, $lname); } #-------------------------------------------------------------------# # parse_jclark_notation() - parse the Clarkian notation #-------------------------------------------------------------------# sub parse_jclark_notation { shift; my $jc = shift; $jc =~ m/^\{(.*)\}([^}]+)$/; return $1, $2; } #-------------------------------------------------------------------# # Java names mapping #-------------------------------------------------------------------# *XML::NamespaceSupport::pushContext = \&push_context; *XML::NamespaceSupport::popContext = \&pop_context; *XML::NamespaceSupport::declarePrefix = \&declare_prefix; *XML::NamespaceSupport::declarePrefixes = \&declare_prefixes; *XML::NamespaceSupport::getPrefix = \&get_prefix; *XML::NamespaceSupport::getPrefixes = \&get_prefixes; *XML::NamespaceSupport::getDeclaredPrefixes = \&get_declared_prefixes; *XML::NamespaceSupport::getURI = \&get_uri; *XML::NamespaceSupport::processName = \&process_name; *XML::NamespaceSupport::processElementName = \&process_element_name; *XML::NamespaceSupport::processAttributeName = \&process_attribute_name; *XML::NamespaceSupport::parseJClarkNotation = \&parse_jclark_notation; *XML::NamespaceSupport::undeclarePrefix = \&undeclare_prefix; 1; __END__ =pod =encoding UTF-8 =head1 NAME XML::NamespaceSupport - A simple generic namespace processor =head1 VERSION version 1.12 =head1 SYNOPSIS use XML::NamespaceSupport; my $nsup = XML::NamespaceSupport->new; # add a new empty context $nsup->push_context; # declare a few prefixes $nsup->declare_prefix($prefix1, $uri1); $nsup->declare_prefix($prefix2, $uri2); # the same shorter $nsup->declare_prefixes($prefix1 => $uri1, $prefix2 => $uri2); # get a single prefix for a URI (randomly) $prefix = $nsup->get_prefix($uri); # get all prefixes for a URI (probably better) @prefixes = $nsup->get_prefixes($uri); # get all prefixes in scope @prefixes = $nsup->get_prefixes(); # get all prefixes that were declared for the current scope @prefixes = $nsup->get_declared_prefixes; # get a URI for a given prefix $uri = $nsup->get_uri($prefix); # get info on a qname (java-ish way, it's a bit weird) ($ns_uri, $local_name, $qname) = $nsup->process_name($qname, $is_attr); # the same, more perlish ($ns_uri, $prefix, $local_name) = $nsup->process_element_name($qname); ($ns_uri, $prefix, $local_name) = $nsup->process_attribute_name($qname); # remove the current context $nsup->pop_context; # reset the object for reuse in another document $nsup->reset; # a simple helper to process Clarkian Notation my ($ns, $lname) = $nsup->parse_jclark_notation('{http://foo}bar'); # or (given that it doesn't care about the object my ($ns, $lname) = XML::NamespaceSupport->parse_jclark_notation('{http://foo}bar'); =head1 DESCRIPTION This module offers a simple to process namespaced XML names (unames) from within any application that may need them. It also helps maintain a prefix to namespace URI map, and provides a number of basic checks. The model for this module is SAX2's NamespaceSupport class, readable at http://www.saxproject.org/namespaces.html It adds a few perlisations where we thought it appropriate. =head1 NAME XML::NamespaceSupport - a simple generic namespace support class =head1 METHODS =over 4 =item * XML::NamespaceSupport->new(\%options) A simple constructor. The options are C, C, and C If C is turned on (it is off by default) the mapping from the xmlns prefix to the URI defined for it in DOM level 2 is added to the list of predefined mappings (which normally only contains the xml prefix mapping). If C is turned off (it is on by default) a number of validity errors will simply be flagged as failures, instead of die()ing. If C is turned on (it is off by default) when one provides a prefix of C to C it will generate a random prefix mapped to that namespace. Otherwise an undef prefix will trigger a warning (you should probably know what you're doing if you turn this option on). If C us turned off, it becomes illegal to undeclare namespace prefixes. It is on by default. This behaviour is compliant with Namespaces in XML 1.1, turning it off reverts you to version 1.0. =item * $nsup->push_context Adds a new empty context to the stack. You can then populate it with new prefixes defined at this level. =item * $nsup->pop_context Removes the topmost context in the stack and reverts to the previous one. It will die() if you try to pop more than you have pushed. =item * $nsup->declare_prefix($prefix, $uri) Declares a mapping of $prefix to $uri, at the current level. Note that with C turned on, if you declare a prefix mapping in which $prefix is undef(), you will get an automatic prefix selected for you. If it is off you will get a warning. This is useful when you deal with code that hasn't kept prefixes around and need to reserialize the nodes. It also means that if you want to set the default namespace (i.e. with an empty prefix) you must use the empty string instead of undef. This behaviour is consistent with the SAX 2.0 specification. =item * $nsup->declare_prefixes(%prefixes2uris) Declares a mapping of several prefixes to URIs, at the current level. =item * $nsup->get_prefix($uri) Returns a prefix given a URI. Note that as several prefixes may be mapped to the same URI, it returns an arbitrary one. It'll return undef on failure. =item * $nsup->get_prefixes($uri) Returns an array of prefixes given a URI. It'll return all the prefixes if the uri is undef. =item * $nsup->get_declared_prefixes Returns an array of all the prefixes that have been declared within this context, ie those that were declared on the last element, not those that were declared above and are simply in scope. Note that at least one context must be added to the stack via C before this method can be called. =item * $nsup->get_uri($prefix) Returns a URI for a given prefix. Returns undef on failure. =item * $nsup->process_name($qname, $is_attr) Given a qualified name and a boolean indicating whether this is an attribute or another type of name (those are differently affected by default namespaces), it returns a namespace URI, local name, qualified name tuple. I know that that is a rather abnormal list to return, but it is so for compatibility with the Java spec. See below for more Perlish alternatives. If the prefix is not declared, or if the name is not valid, it'll either die or return undef depending on the current setting of C. =item * $nsup->undeclare_prefix($prefix); Removes a namespace prefix from the current context. This function may be used in SAX's end_prefix_mapping when there is fear that a namespace declaration might be available outside their scope (which shouldn't normally happen, but you never know ;) ). This may be needed in order to properly support Namespace 1.1. =item * $nsup->process_element_name($qname) Given a qualified name, it returns a namespace URI, prefix, and local name tuple. This method applies to element names. If the prefix is not declared, or if the name is not valid, it'll either die or return undef depending on the current setting of C. =item * $nsup->process_attribute_name($qname) Given a qualified name, it returns a namespace URI, prefix, and local name tuple. This method applies to attribute names. If the prefix is not declared, or if the name is not valid, it'll either die or return undef depending on the current setting of C. =item * $nsup->reset Resets the object so that it can be reused on another document. =back All methods of the interface have an alias that is the name used in the original Java specification. You can use either name interchangeably. Here is the mapping: Java name Perl name --------------------------------------------------- pushContext push_context popContext pop_context declarePrefix declare_prefix declarePrefixes declare_prefixes getPrefix get_prefix getPrefixes get_prefixes getDeclaredPrefixes get_declared_prefixes getURI get_uri processName process_name processElementName process_element_name processAttributeName process_attribute_name parseJClarkNotation parse_jclark_notation undeclarePrefix undeclare_prefix =head1 VARIABLES Two global variables are made available to you. They used to be constants but simple scalars are easier to use in a number of contexts. They are not exported but can easily be accessed from any package, or copied into it. =over 4 =item * C<$NS_XMLNS> The namespace for xmlns prefixes, http://www.w3.org/2000/xmlns/. =item * C<$NS_XML> The namespace for xml prefixes, http://www.w3.org/XML/1998/namespace. =back =head1 TODO - add more tests - optimise here and there =head1 SEE ALSO XML::Parser::PerlSAX =head1 AUTHORS =over 4 =item * Robin Berjon =item * Chris Prather =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2015 by Robin Berjon. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =head1 CONTRIBUTORS =for stopwords Chris Prather David Steinbrunner Paul Cochrane Paulo Custodio =over 4 =item * Chris Prather =item * David Steinbrunner =item * Paul Cochrane =item * Paulo Custodio =back =cut