XML-Spice-0.05/000755 000765 000024 00000000000 13012002047 013227 5ustar00robnstaff000000 000000 XML-Spice-0.05/Changes000644 000765 000024 00000000523 13012002047 014522 0ustar00robnstaff000000 000000 0.05 2016-11-13 17:11:49+11:00 Australia/Melbourne - No changes; just licensing updates 0.04 Jun 02 2014 Add pretty-printing option for debugging 0.03 Nov 14 2013 Handle "false" serialised values correctly 0.02 Aug 26 2010 Escape numerics 0.01 Oct 13 2009 First release XML-Spice-0.05/LICENSE000644 000765 000024 00000043660 13012002047 014245 0ustar00robnstaff000000 000000 This software is copyright (c) 2016 by Robert Norris. 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) 2016 by Robert Norris. 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) 2016 by Robert Norris. 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 XML-Spice-0.05/MANIFEST000644 000765 000024 00000000417 13012002047 014362 0ustar00robnstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.008. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/XML/Spice.pm t/00-load.t t/05-import.t t/10-coderef.t t/10-generation.t t/10-misc.t t/10-namespaces.t t/10-tags.t XML-Spice-0.05/META.json000644 000765 000024 00000027116 13012002047 014657 0ustar00robnstaff000000 000000 { "abstract" : "generating XML has never been so Perly!", "author" : [ "Robert Norris " ], "dynamic_config" : 1, "generated_by" : "Dist::Zilla version 6.008, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "XML-Spice", "optional_features" : { "PrettyPrinting" : { "description" : "Pretty printing", "prereqs" : { "runtime" : { "requires" : { "XML::Tidy::Tiny" : "0" } } } } }, "prereqs" : { "configure" : { "requires" : { "CPAN::Meta::Requirements" : "2.120620", "ExtUtils::MakeMaker" : "0", "Module::Metadata" : "0" } }, "develop" : { "requires" : { "XML::Tidy::Tiny" : "0" } }, "runtime" : { "requires" : { "Carp" : "0", "XML::Tidy::Tiny" : "0", "overload" : "0", "perl" : "5.008", "strict" : "0", "warnings" : "0" }, "suggests" : { "XML::Tidy::Tiny" : "0" } }, "test" : { "requires" : { "Test::More" : "0", "Test::XML" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/robn/XML-Spice/issues" }, "homepage" : "https://github.com/robn/XML-Spice", "repository" : { "type" : "git", "url" : "https://github.com/robn/XML-Spice.git", "web" : "https://github.com/robn/XML-Spice" } }, "version" : "0.05", "x_Dist_Zilla" : { "perl" : { "version" : "5.024000" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@Filter/PruneCruft", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Filter/ManifestSkip", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Filter/MetaYAML", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@Filter/License", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@Filter/Readme", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::ExtraTests", "name" : "@Filter/ExtraTests", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Filter/ExecDir", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Filter/ShareDir", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Filter/MakeMaker", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Filter/Manifest", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@Filter/TestRelease", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Filter/ConfirmRelease", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@Filter/UploadToCPAN", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [ "Makefile.PL" ], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." } }, "name" : "GatherDir", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "AutoPrereqs", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::OptionalFeature", "config" : { "Dist::Zilla::Plugin::OptionalFeature" : { "always_recommend" : 0, "always_suggest" : 1, "check_prereqs" : 1, "description" : "Pretty printing", "name" : "PrettyPrinting", "phase" : "runtime", "prereqs" : { "XML::Tidy::Tiny" : "0" }, "prompt" : 1, "require_develop" : 1, "type" : "requires" } }, "name" : "PrettyPrinting", "version" : "0.023" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "PkgVersion", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "MetaConfig", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "MetaJSON", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "NextRelease", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::GithubMeta", "name" : "GithubMeta", "version" : "0.54" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "config" : { "Dist::Zilla::Plugin::Git::Check" : { "untracked_files" : "die" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ ".travis.yml", "Changes", "Makefile.PL", "dist.ini" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@Git/Check", "version" : "2.039" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "v%v%n%n%c" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ ".travis.yml", "Changes", "Makefile.PL", "dist.ini" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@Git/Commit", "version" : "2.039" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "config" : { "Dist::Zilla::Plugin::Git::Tag" : { "branch" : null, "changelog" : "Changes", "signed" : 0, "tag" : "0.05", "tag_format" : "%v", "tag_message" : "v%v" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@Git/Tag", "version" : "2.039" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "config" : { "Dist::Zilla::Plugin::Git::Push" : { "push_to" : [ "origin" ], "remotes_must_exist" : 1 }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@Git/Push", "version" : "2.039" }, { "class" : "Dist::Zilla::Plugin::TravisYML", "name" : "TravisYML", "version" : "1.15" }, { "class" : "Dist::Zilla::Plugin::ReadmeAnyFromPod", "config" : { "Dist::Zilla::Role::FileWatcher" : { "version" : "0.006" } }, "name" : "MarkdownInRoot", "version" : "0.161170" }, { "class" : "Dist::Zilla::Plugin::CopyFilesFromBuild", "name" : "CopyFilesFromBuild", "version" : "0.161350" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::DynamicPrereqs", "config" : { "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000033", "version" : "0.004" } }, "name" : "via OptionalFeature", "version" : "0.032" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : 0 }, "version" : "6.008" } }, "x_serialization_backend" : "Cpanel::JSON::XS version 3.0217" } XML-Spice-0.05/META.yml000644 000765 000024 00000016312 13012002047 014503 0ustar00robnstaff000000 000000 --- abstract: 'generating XML has never been so Perly!' author: - 'Robert Norris ' build_requires: Test::More: '0' Test::XML: '0' configure_requires: CPAN::Meta::Requirements: '2.120620' ExtUtils::MakeMaker: '0' Module::Metadata: '0' dynamic_config: 1 generated_by: 'Dist::Zilla version 6.008, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: XML-Spice optional_features: PrettyPrinting: description: 'Pretty printing' requires: XML::Tidy::Tiny: '0' requires: Carp: '0' XML::Tidy::Tiny: '0' overload: '0' perl: '5.008' strict: '0' warnings: '0' resources: bugtracker: https://github.com/robn/XML-Spice/issues homepage: https://github.com/robn/XML-Spice repository: https://github.com/robn/XML-Spice.git version: '0.05' x_Dist_Zilla: perl: version: '5.024000' plugins: - class: Dist::Zilla::Plugin::PruneCruft name: '@Filter/PruneCruft' version: '6.008' - class: Dist::Zilla::Plugin::ManifestSkip name: '@Filter/ManifestSkip' version: '6.008' - class: Dist::Zilla::Plugin::MetaYAML name: '@Filter/MetaYAML' version: '6.008' - class: Dist::Zilla::Plugin::License name: '@Filter/License' version: '6.008' - class: Dist::Zilla::Plugin::Readme name: '@Filter/Readme' version: '6.008' - class: Dist::Zilla::Plugin::ExtraTests name: '@Filter/ExtraTests' version: '6.008' - class: Dist::Zilla::Plugin::ExecDir name: '@Filter/ExecDir' version: '6.008' - class: Dist::Zilla::Plugin::ShareDir name: '@Filter/ShareDir' version: '6.008' - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Filter/MakeMaker' version: '6.008' - class: Dist::Zilla::Plugin::Manifest name: '@Filter/Manifest' version: '6.008' - class: Dist::Zilla::Plugin::TestRelease name: '@Filter/TestRelease' version: '6.008' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Filter/ConfirmRelease' version: '6.008' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@Filter/UploadToCPAN' version: '6.008' - class: Dist::Zilla::Plugin::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: - Makefile.PL exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: . name: GatherDir version: '6.008' - class: Dist::Zilla::Plugin::AutoPrereqs name: AutoPrereqs version: '6.008' - class: Dist::Zilla::Plugin::OptionalFeature config: Dist::Zilla::Plugin::OptionalFeature: always_recommend: 0 always_suggest: 1 check_prereqs: '1' description: 'Pretty printing' name: PrettyPrinting phase: runtime prereqs: XML::Tidy::Tiny: '0' prompt: 1 require_develop: 1 type: requires name: PrettyPrinting version: '0.023' - class: Dist::Zilla::Plugin::PkgVersion name: PkgVersion version: '6.008' - class: Dist::Zilla::Plugin::MetaConfig name: MetaConfig version: '6.008' - class: Dist::Zilla::Plugin::MetaJSON name: MetaJSON version: '6.008' - class: Dist::Zilla::Plugin::NextRelease name: NextRelease version: '6.008' - class: Dist::Zilla::Plugin::GithubMeta name: GithubMeta version: '0.54' - class: Dist::Zilla::Plugin::Git::Check config: Dist::Zilla::Plugin::Git::Check: untracked_files: die Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - .travis.yml - Changes - Makefile.PL - dist.ini allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . name: '@Git/Check' version: '2.039' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: v%v%n%n%c Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - .travis.yml - Changes - Makefile.PL - dist.ini allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@Git/Commit' version: '2.039' - class: Dist::Zilla::Plugin::Git::Tag config: Dist::Zilla::Plugin::Git::Tag: branch: ~ changelog: Changes signed: 0 tag: '0.05' tag_format: '%v' tag_message: v%v Dist::Zilla::Role::Git::Repo: repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@Git/Tag' version: '2.039' - class: Dist::Zilla::Plugin::Git::Push config: Dist::Zilla::Plugin::Git::Push: push_to: - origin remotes_must_exist: 1 Dist::Zilla::Role::Git::Repo: repo_root: . name: '@Git/Push' version: '2.039' - class: Dist::Zilla::Plugin::TravisYML name: TravisYML version: '1.15' - class: Dist::Zilla::Plugin::ReadmeAnyFromPod config: Dist::Zilla::Role::FileWatcher: version: '0.006' name: MarkdownInRoot version: '0.161170' - class: Dist::Zilla::Plugin::CopyFilesFromBuild name: CopyFilesFromBuild version: '0.161350' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '6.008' - class: Dist::Zilla::Plugin::DynamicPrereqs config: Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000033' version: '0.004' name: 'via OptionalFeature' version: '0.032' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '6.008' x_serialization_backend: 'YAML::Tiny version 1.69' XML-Spice-0.05/Makefile.PL000644 000765 000024 00000005432 13012002047 015205 0ustar00robnstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.008. use strict; use warnings; use 5.008; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "generating XML has never been so Perly!", "AUTHOR" => "Robert Norris ", "CONFIGURE_REQUIRES" => { "CPAN::Meta::Requirements" => "2.120620", "ExtUtils::MakeMaker" => 0, "Module::Metadata" => 0 }, "DISTNAME" => "XML-Spice", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.008", "NAME" => "XML::Spice", "PREREQ_PM" => { "Carp" => 0, "XML::Tidy::Tiny" => 0, "overload" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "Test::More" => 0, "Test::XML" => 0 }, "VERSION" => "0.05", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "Test::More" => 0, "Test::XML" => 0, "XML::Tidy::Tiny" => 0, "overload" => 0, "strict" => 0, "warnings" => 0 ); # inserted by Dist::Zilla::Plugin::DynamicPrereqs 0.032 requires('XML::Tidy::Tiny') if has_module('XML::Tidy::Tiny') || prompt('install Pretty printing? [y/N]', 'N') =~ /^y/i; 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); # inserted by Dist::Zilla::Plugin::DynamicPrereqs 0.032 sub _add_prereq { my ($mm_key, $module, $version_or_range) = @_; $version_or_range ||= 0; warn "$module already exists in $mm_key -- need to do a sane metamerge!" if exists $WriteMakefileArgs{$mm_key}{$module} and $WriteMakefileArgs{$mm_key}{$module} ne '0' and $WriteMakefileArgs{$mm_key}{$module} ne $version_or_range; warn "$module already exists in FallbackPrereqs -- need to do a sane metamerge!" if exists $FallbackPrereqs{$module} and $FallbackPrereqs{$module} ne '0' and $FallbackPrereqs{$module} ne $version_or_range; $WriteMakefileArgs{$mm_key}{$module} = $FallbackPrereqs{$module} = $version_or_range; return; } sub has_module { my ($module, $version_or_range) = @_; require Module::Metadata; my $mmd = Module::Metadata->new_from_module($module); return undef if not $mmd; return $mmd->version($module) if not defined $version_or_range; require CPAN::Meta::Requirements; my $req = CPAN::Meta::Requirements->new; $req->add_string_requirement($module => $version_or_range); return 1 if $req->accepts_module($module => $mmd->version($module)); return 0; } sub requires { goto &runtime_requires } sub runtime_requires { my ($module, $version_or_range) = @_; _add_prereq(PREREQ_PM => $module, $version_or_range); } XML-Spice-0.05/README000644 000765 000024 00000000565 13012002047 014115 0ustar00robnstaff000000 000000 This archive contains the distribution XML-Spice, version 0.05: generating XML has never been so Perly! This software is copyright (c) 2016 by Robert Norris. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v6.008. XML-Spice-0.05/dist.ini000644 000765 000024 00000001313 13012002047 014671 0ustar00robnstaff000000 000000 name = XML-Spice author = Robert Norris license = Perl_5 copyright_holder = Robert Norris copyright_year = 2016 version = 0.05 [@Filter] -bundle = @Basic -remove = GatherDir [GatherDir] exclude_filename = Makefile.PL [AutoPrereqs] [OptionalFeature / PrettyPrinting ] -description = Pretty printing XML::Tidy::Tiny = 0 [PkgVersion] die_on_existing_version = 1 die_on_line_insertion = 1 [MetaConfig] [MetaJSON] [NextRelease] [GithubMeta] issues = 1 [@Git] tag_format = %v allow_dirty = Changes allow_dirty = dist.ini allow_dirty = Makefile.PL allow_dirty = .travis.yml [TravisYML] [ReadmeAnyFromPod / MarkdownInRoot] filename = README.md [CopyFilesFromBuild] copy = Makefile.PL XML-Spice-0.05/lib/000755 000765 000024 00000000000 13012002047 013775 5ustar00robnstaff000000 000000 XML-Spice-0.05/t/000755 000765 000024 00000000000 13012002047 013472 5ustar00robnstaff000000 000000 XML-Spice-0.05/t/00-load.t000644 000765 000024 00000000214 13012002047 015010 0ustar00robnstaff000000 000000 #!perl -T use Test::More tests => 1; BEGIN { use_ok( 'XML::Spice' ); } diag( "Testing XML::Spice $XML::Spice::VERSION, Perl $], $^X" ); XML-Spice-0.05/t/05-import.t000644 000765 000024 00000001241 13012002047 015411 0ustar00robnstaff000000 000000 #!perl -T use warnings; use strict; use Test::More tests => 5; # deliberately don't import BEGIN { require XML::Spice; } # no args pulls in x() and nothing more package noargs; import XML::Spice; main::ok(__PACKAGE__->can("x"), "x() should be imported by default"); # create some generators, these shouldn't bring in x() package nox; import XML::Spice qw(foo bar baz); main::ok(__PACKAGE__->can("foo"), "foo() should be imported"); main::ok(__PACKAGE__->can("bar"), "bar() should be imported"); main::ok(__PACKAGE__->can("baz"), "baz() should be imported"); main::ok(!__PACKAGE__->can("x"), "x() should not be imported when tags are explicitly asked for"); XML-Spice-0.05/t/10-coderef.t000644 000765 000024 00000001400 13012002047 015477 0ustar00robnstaff000000 000000 #!perl -T use warnings; use strict; use Test::More tests => 5; use Test::XML; use XML::Spice; is_xml( qq(text), x("tag", sub { "text" }), "basic text substitution"); is_xml( qq(thunk), x("tag", sub { x("sub", "thunk") }), "tree substitution"); my $count = 0; sub inc { return $count++; } is_xml( qq(012), x("count", map { x("val", \&inc) } (0..2)), "lazy evaluation"); sub deeper { return x("deeper"); } is_xml( qq(), x("deep", sub { return \&deeper; }), "nested coderefs"); is_xml( qq(), x("foo", sub { return { "bar" => "baz" }}), "coderefs can return attribute hashes"); XML-Spice-0.05/t/10-generation.t000644 000765 000024 00000006421 13012002047 016233 0ustar00robnstaff000000 000000 #!perl -T use warnings; use strict; use Test::More tests => 16; use Test::XML; use XML::Spice; my @tests = ( "single tag", qq(), sub { x("tag"); }, "single tag, single subtag", qq(), sub { x("tag", x("sub")); }, "multiple subtags, single level", qq(), sub { x("meta", x("foo"), x("bar"), x("baz")); }, "two levels of subtags", qq(), sub { x("one", x("two", x("three")), x("four", x("five", x("six")))); }, "single tag with attributes", qq(), sub { x("tag", { foo => "bar", baz => "quux" }); }, "subtag with attributes", qq(), sub { x("tag", x("subtag", { foo => "bar", baz => "quux" })); }, "different tags with different attributes", qq(), sub { x("tag", { level => 1 }, x("subtag", { level => 2 })); }, "something arrayish", qq(), sub { x("perlzoo", x("animal", { type => "camel" }), x("animal", { type => "llama" }), x("animal", { type => "dog" })); }, "single tag with text", qq(value), sub { x("tag", "value"); }, "subtag with text", qq(value), sub { x("tag", x("sub", "value")); }, "arrayish text", qq(foobarbaz), sub { x("words", x("weird", "foo"), x("weird", "bar"), x("weird", "baz")); }, "more than one text bit", qq(together we make a sentence), sub { x("text", "together we make ", "a sentence"); }, "text mixed with subtags", qq(

this text is bold, while this is italicised.

), sub { x("p", "this text is ", x("b", "bold"), ", while this is ", x("i", "italicised"), "."); }, "escaping", qq(&<>"), sub { x("escapes", '&<>"'); }, "numeric escaping", qq().join('', (map { sprintf '&#%d;', $_ } (0x20 .. 0xd7ff))).qq(), sub { x("escapes", join '', (map { chr($_) } (0x20 .. 0xd7ff))); }, "0 as cdata works", qq(0), sub { x("foo", 0); }, ); while(@tests > 1) { my $desc = shift @tests; my $xml = shift @tests; my $gen = shift @tests; is_xml($xml, &{$gen}(), $desc); } diag("test set had leftover items, probable bug in $0") if @tests > 0; XML-Spice-0.05/t/10-misc.t000644 000765 000024 00000002322 13012002047 015027 0ustar00robnstaff000000 000000 #!perl -T use warnings; use strict; use Test::More tests => 8; use Test::XML; use XML::Spice; is_xml(x("foo", "bar", x("what", "lol")), x("foo", undef, "bar", x("what", "lol", ""), undef), "undefs and empty strings are silently ignored"); is_xml(x("foo", [ "bar", [ x("baz", "quux"), "what" ], "lol" ]), x("foo", "bar", x("baz", "quux"), "what", "lol"), "array refs get flattened"); is_xml(x("foo", { "bar" => "baz" }, { "what" => "lol" }), x("foo", { "bar" => "baz", "what" => "lol" }), "attribute hashes get combined"); is_xml(x("foo", { "bar" => "baz" }, { "what" => undef }), x("foo", { "bar" => "baz" }), "and undef values get ignored"); is_xml(x("foo", { "bar" => "baz" }, { "bar" => undef }), x("foo"), "or cause a previously-supplied attribute to be removed"); my $count = 0; sub inc { return $count++; } my $xml = x("foo", \&inc); my $x0 = "".$xml; is_xml(q(0), $xml, "return is cached after initial stringification"); is_xml(q(0), $xml, "and continues to be"); $xml->forget; is_xml(q(1), $xml, "but gets re-evaluated after forgetting the cached value"); XML-Spice-0.05/t/10-namespaces.t000644 000765 000024 00000001660 13012002047 016217 0ustar00robnstaff000000 000000 #!perl -T use warnings; use strict; use Test::More tests => 4; use Test::XML; use XML::Spice; my @tests = ( "namespaces as attributes", qq(), sub { x("tag", { xmlns => "foo" }); }, "tag prefixes", qq(), sub { x("tag", { xmlns => "foo" }); }, "attribute prefixes", qq(), sub { x("tag", { "xmlns:a" => "bar", "a:attr" => "what" }); }, "mixed tags and attributes", qq(), sub { x("tag", { xmlns => "foo", "xmlns:p" => "bar" }, x("p:tag")); }, ); while(@tests > 1) { my $desc = shift @tests; my $xml = shift @tests; my $gen = shift @tests; is_xml($xml, &{$gen}(), $desc); } diag("test set had leftover items, probable bug in $0") if @tests > 0; XML-Spice-0.05/t/10-tags.t000644 000765 000024 00000004750 13012002047 015041 0ustar00robnstaff000000 000000 #!perl -T use warnings; use strict; use Test::More tests => 22; use Test::XML; use XML::Spice qw( html body p ul li ); import XML::Spice; # get x() as well is_xml(html(), x("html"), "same output for 'html'"); is_xml(body(), x("body"), "same output for 'body'"); is_xml(p(), x("p"), "same output for 'p'"); is_xml(ul(), x("ul"), "same output for 'ul'"); is_xml(li(), x("li"), "same output for 'li'"); is_xml(html("foo"), x("html", "foo"), "same output for 'html' with text"); is_xml(body("foo"), x("body", "foo"), "same output for 'body' with text"); is_xml(p("foo"), x("p", "foo"), "same output for 'p' with text"); is_xml(ul("foo"), x("ul", "foo"), "same output for 'ul' with text"); is_xml(li("foo"), x("li", "foo"), "same output for 'li' with text"); my $attrs = { foo => "bar" }; is_xml(html($attrs), x("html", $attrs), "same output for 'html' with attributes"); is_xml(body($attrs), x("body", $attrs), "same output for 'body' with attributes"); is_xml(p($attrs), x("p", $attrs), "same output for 'p' with attributes"); is_xml(ul($attrs), x("ul", $attrs), "same output for 'ul' with attributes"); is_xml(li($attrs), x("li", $attrs), "same output for 'li' with attributes"); is_xml(html($attrs, "foo"), x("html", $attrs, "foo"), "same output for 'html' with text and attributes"); is_xml(body($attrs, "foo"), x("body", $attrs, "foo"), "same output for 'body' with text and attributes"); is_xml(p($attrs, "foo"), x("p", $attrs, "foo"), "same output for 'p' with text and attributes"); is_xml(ul($attrs, "foo"), x("ul", $attrs, "foo"), "same output for 'ul' with text and attributes"); is_xml(li($attrs, "foo"), x("li", $attrs, "foo"), "same output for 'li' with text and attributes"); is_xml( html( body( p({ class => "yellow" }, "words:", ul( li("foo"), li("bar"), li("baz"))))), x("html", x("body", x("p", { class => "yellow" }, "words:", x("ul", x("li", "foo"), x("li", "bar"), x("li", "baz"))))), "same output for document"); is_xml( html( body( x("h1", { style => "color: blue;" }, "my life"), p("its great"))), x("html", x("body", x("h1", { style => "color: blue;" }, "my life"), x("p", "its great"))), "same output for document with mixed tag/x calls"); XML-Spice-0.05/lib/XML/000755 000765 000024 00000000000 13012002047 014435 5ustar00robnstaff000000 000000 XML-Spice-0.05/lib/XML/Spice.pm000644 000765 000024 00000031132 13012002047 016036 0ustar00robnstaff000000 000000 package XML::Spice; $XML::Spice::VERSION = '0.05'; # ABSTRACT: generating XML has never been so Perly! require 5.008; use warnings; use strict; use Carp; our $PRETTY_PRINT = 0; sub import { my ($pkg, @args) = @_; my $them = caller(); if (@args) { for my $arg (@args) { croak "Invalid element name '$arg'" if $arg !~ m/^[A-Za-z]\w*$/; { no strict "refs"; *{$them."::".$arg} = sub { x($arg, @_) }; } } } else { no strict "refs"; *{$them."::x"} = \&x; } } sub x { my ($tag, @args) = @_; my $chunk = { tag => $tag, attrs => {}, }; for my $arg (@args) { if (ref $arg eq "HASH") { for my $key (keys %$arg) { if (!defined $arg->{$key}) { delete $chunk->{attrs}->{$key}; } else { $chunk->{attrs}->{$key} = "".$arg->{$key}; } } } else { push @{$chunk->{sub}}, $arg; } } return bless $chunk, "XML::Spice::Chunk"; } package # hide from PAUSE XML::Spice::Chunk; use warnings; use strict; use Carp; use overload '""' => \&_xml; my $TIDY_LOADED; sub _xml { my ($chunk) = @_; if ($PRETTY_PRINT && !defined $TIDY_LOADED) { eval { require XML::Tidy::Tiny }; if ($@) { carp "Couldn't load XML::Tidy::Tiny: $@"; $TIDY_LOADED = 0; } else { $TIDY_LOADED = 1; } } my $WANT_PRETTY = $PRETTY_PRINT && $TIDY_LOADED; return $chunk->{cached} if exists $chunk->{cached} && !$WANT_PRETTY; sub _escape_attr { my ($val) = @_; $val =~ s/'/'/g; return $val; } sub _escape_cdata { my ($val) = @_; $val =~ s/&/&/g; $val =~ s//>/g; $val =~ s/"/"/g; $val =~ s/([^\x20-\x7E])/'&#' . ord($1) . ';'/ge; return $val; } sub _serialise { my ($chunk, @things) = @_; my $xml = ''; for my $thing (@things) { next if ! defined $thing; if (ref $thing eq "CODE") { $thing = &{$thing}; if (ref $thing eq "HASH") { for my $key (keys %$thing) { if (!defined $thing->{$key}) { delete $chunk->{attrs}->{$key}; } else { $chunk->{attrs}->{$key} = "".$thing->{$key}; } } undef $thing; } redo; } if (ref $thing eq "ARRAY") { $xml .= $chunk->_serialise(@$thing); } elsif (ref $thing eq "XML::Spice::Chunk") { $xml .= $thing->_xml; } else { next if $thing eq ""; $xml .= _escape_cdata($thing); } } return $xml; } my $subxml = $chunk->_serialise(@{$chunk->{sub}}) if exists $chunk->{sub}; my $xml = "<" . $chunk->{tag}; for my $attr (keys %{$chunk->{attrs}}) { $xml .= " $attr='" . _escape_attr($chunk->{attrs}->{$attr}) . "'"; } if (!defined $subxml) { $xml .= "/>"; $chunk->{cached} = $xml unless $WANT_PRETTY; return $WANT_PRETTY ? XML::Tidy::Tiny::xml_tidy($xml) : $xml; } $xml .= ">" . $subxml . "{tag} . ">"; $chunk->{cached} = $xml unless $WANT_PRETTY; return $WANT_PRETTY ? XML::Tidy::Tiny::xml_tidy($xml) : $xml; } sub forget { my ($chunk) = @_; delete $chunk->{cached}; } 1; __END__ =pod =encoding UTF-8 =for markdown [![Build Status](https://secure.travis-ci.org/robn/XML-Spice.png)](http://travis-ci.org/robn/XML-Spice) =head1 NAME XML::Spice - generating XML has never been so Perly! =head1 SYNOPSIS use XML::Spice qw(html head title body h1 p a); print html( head( title("my great page"), ), body( h1("my great page"), p("this is my great page, made with ", a("spice", { href => "http://en.wikipedia.org/wiki/Spice/" }), ), ), ); =head1 DESCRIPTION XML::Spice is yet another XML generation module. It tries to take some of the pain out of generating XML by making it more like Perl. Unless you've got a really good module for producing XML for your particular use (like a module for interfacing with a specific web service), you've probably found that you end up resorting to code like this: my $xml = q{}; Of course this works great, and you can't beat it for speed, but it quickly becomes difficult to work with. Your syntax highlighting probably just displays it as a giant string. You can't easily see mismatched brackets or other bugs until your code runs and tries to parse the thing. And, once you start adding attributes and character data into the mix, it rapidly moves towards being impossible to read. Instead of this, you could use XML::Spice and write the same thing in Perl: my $xml = foo(bar(baz()), quux()); You'll can add liberal amounts of whitespace to convey structure without it making your output larger. You get Perl checking to make sure that you haven't left anything out. You can use all the power of Perl to generate and include data without having to pepper your code with interpolated strings or concatenation operators. And you get a guarantee that the XML produced is valid. =head1 BASIC USAGE If you C (or C) XML::Spice without any arguments, it will export a single function C into your package. This is the only real function in XML::Spice, and its used to implement everything else. C generates a single element, which in turn can contain attributes, character data, sub-elements (via additional calls to C), and more. The general format for C is: my $xml = x("element", ...); The first argument is required, and is always the name of the element to generate. So C produces Cfoo/E>. Generally though, you'll want to use the more readable named functions to do the work. You get these by providing arguments to XML::Spice when you C it (or call C). For example: use XML::Spice qw(foo bar baz); This will export three functions into your package, C, C and C, and I import C. Calling these functions produces the same results as calling C with the name as the first argument, that is: my $xml = foo(...); produces identical results to: my $xml = x("foo", ...); C returns an C object, which when stringified (ie Ced or interpolated into a string) produces the XML of its input. Generally you won't care, you'll just stringify it and be done with it. There are however some rather clever things that can be done by having the return value be an object instead of a normal string; see L for details. =head1 ARGUMENTS C can take zero or more additional arguments. These arguments define what else gets added to the element. What happens depends on what you pass. =over =item attributes Attributes are added to the element by passing a hash reference, eg: img({ src => "hello.jpg" }); produces: If you pass multiple hash references, their contents are combined, with the value from the last hash passed being used in the case of a conflict. =item sub-elements Sub-elements are included in an element by passing the output from another call to C, eg: foo(bar()); produces: =item character data Character data is added to the element by passing simple strings, eg: p("this is my paragraph"); produces:

this is my paragraph

=back These arguments can be mixed as much as you like, eg: p("Visit my ", a({ href => "http://homepage.com/"}, "homepage"), " for more information."); produces:

Visit my homepage for more information.

Other things can be passed to C; those are described in L. =head1 ADVANCED USAGE =head2 Dynamic tree generation The most important thing to understand about the C objects returned by C is that they do nothing until they are stringified to produce XML output. This makes it possible to pass code references or even other objects to C and have them dynamically generate data to be included in the produced XML. If a code reference is passed to C, it is called when the resultant C is stringified and its output is included at the position that the code reference was at, eg: p("the time is ", sub { scalar localtime }); would produce something like:

the time is Sat Sep 26 22:32:57 2009

C will recursively evaluate the result from the code reference until it gets down to basic strings and hash references as described in L. This is great for producing lists of things, eg: my $list = ul(sub { my @results; opendir my $dir, "images"; push @results, li($_) for grep { m/\.png$/ } readdir $dir; closedir $dir; return @results; }); When C<$list> is stringified, the sub will be called and would return a list of C objects. These in turn will be stringified until eventually only strings are left and output like the following is produced:
  • foo.png
  • bar.png
  • baz.png
Had the sub itself returned a code reference, then that in turn would have been called and its output used. The code reference is called every time the C object is stringified. If the computed result will not change, consider caching the result. To support this, the following things may be passed to C (and thus returned by code references or objects): =over =item undef If C is passed to C, it is ignored. That is: foo("bar", undef, "baz"); is exactly equivalent to: foo("bar", "baz"); and produces: barbaz =item array reference If an array reference is passed to C, it is flattened. That is: foo("bar", [ baz(), "quux" ]); is exactly equivalent to: foo("bar", baz(), "quux"); and produces: barquux =back =head2 Result cache A chunk is only evaluated the first time it is stringified. The result is cached and each subsequent stringification will return the cached result. If you wanted to reuse a chunk (eg if it has a coderef in it that does a database lookup), you can call its C method to remove the cached result. The next time it is stringified it will be reevaluated from scratch. =head1 PRETTY PRINTING C can produce pretty-printed output. Because the additional whitespace subtly changes the semantics of the generated XML this is only intended as a debugging feature. This also disables the result cache. To use it, you'll need the L module installed. Then to enable it, set (and localise!) C<$XML::Spice::PRETTY_PRINT> to a true value before stringifying a chunk. =head1 TODO =over =item Optimised namespace declarations If two sub-chunks declare the same namespace, then move the declaration to the parent chunk. =back =head1 BUGS AND LIMITATIONS This module guarantees that the XML it produces will be valid and semantically equivalent to the input you give it, but it makes no guarantees and gives no control over things like use of entity encoding vs. CDATA sections, declaration of namespaces and use of prefixes, and so forth. The method used may change between releases, producing different results. If you require exact control over the details of the XML produced, then this module is not for you. =head1 SUPPORT =head2 Bugs / Feature Requests Please report any bugs or feature requests through the issue tracker at L. You will be notified automatically of any progress on your issue. =head2 Source Code This is open source software. The code repository is available for public review and contribution under the terms of the license. L git clone https://github.com/robn/XML-Spice.git =head1 AUTHORS =over 4 =item * Robert Norris =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2006-2016 by Robert Norris. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut