| 1 | package XML::Grammar::Vered; | ||
| 2 | $XML::Grammar::Vered::VERSION = '0.2.0'; | ||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 2 | ▶ | use 5.008; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 2 | ▶ | use autodie; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 2 | ▶ | use MooX qw/late/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 2 | ▶ | use XML::GrammarBase::Role::RelaxNG v0.2.2; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 2 | ▶ | use XML::GrammarBase::Role::XSLT v0.2.2; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 14 | |||
| 15 | with('XML::GrammarBase::Role::RelaxNG'); | ||
| 16 | with XSLT( output_format => 'docbook' ); | ||
| 17 | |||
| 18 | has '+module_base' => ( default => 'XML-Grammar-Vered' ); | ||
| 19 | has '+rng_schema_basename' => ( default => 'vered-xml.rng' ); | ||
| 20 | |||
| 21 | has '+to_docbook_xslt_transform_basename' => | ||
| 22 | ( default => 'vered-xml-to-docbook.xslt' ); | ||
| 23 | |||
| 24 | has '_mode' => ( is => 'rw', init_arg => 'mode' ); | ||
| 25 | has '_output_mode' => ( is => 'rw', init_arg => 'output_mode', ); | ||
| 26 | |||
| 27 | 1; | ||
| 28 | |||
| 29 | __END__ | ||
| 30 | |||
| 31 | =pod | ||
| 32 | |||
| 33 | =encoding UTF-8 | ||
| 34 | |||
| 35 | =head1 NAME | ||
| 36 | |||
| 37 | XML::Grammar::Vered - a vered by any other name will translate as sweet. | ||
| 38 | |||
| 39 | =head1 VERSION | ||
| 40 | |||
| 41 | version 0.2.0 | ||
| 42 | |||
| 43 | =head1 SYNOPSIS | ||
| 44 | |||
| 45 | my $xslt = XML::Grammar::Vered->new( | ||
| 46 | data_dir => "/path/to/data-dir", | ||
| 47 | ); | ||
| 48 | |||
| 49 | my $input_filename = '/path/to/my-file-in-vered-format.xml'; | ||
| 50 | # Throws an exception on failure. | ||
| 51 | my $as_docbook = $xslt->perform_xslt_translation( | ||
| 52 | { | ||
| 53 | output_format => 'docbook' | ||
| 54 | source => {file => $input_filename, }, | ||
| 55 | output => "string", | ||
| 56 | } | ||
| 57 | ); | ||
| 58 | |||
| 59 | =head1 DESCRIPTION | ||
| 60 | |||
| 61 | Vered-XML is a custom (and incredibly ad-hoc) XML grammar, which was created | ||
| 62 | for the ability to more easily write and maintain the “Perl Elements to | ||
| 63 | Avoid” page over at L<http://perl-begin.org/tutorials/bad-elements/> . You | ||
| 64 | may find it suitable, but chances are you won't. If you find it lacking in | ||
| 65 | a certain respect, you can either send me a diff to the RNG and XSLT (and | ||
| 66 | hopefully automated tests as well), or file a bug report and I'll see what | ||
| 67 | I can do. | ||
| 68 | |||
| 69 | Vered gets translated to DocBook 5/XML, and from there to other formats. | ||
| 70 | |||
| 71 | “Vered” is the Hebrew word for “a rose”, and I came up with the name because | ||
| 72 | I did not know what to call this format, and thought of “a rose by any other | ||
| 73 | name will smell as sweet”. | ||
| 74 | |||
| 75 | =head1 EXAMPLE | ||
| 76 | |||
| 77 | <?xml version="1.0" encoding="utf-8"?> | ||
| 78 | <document xmlns="http://www.shlomifish.org/open-source/projects/XML-Grammar/Vered/" xmlns:xlink="http://www.w3.org/1999/xlink" version="0.2.0" xml:lang="en-GB" xml:id="index"> | ||
| 79 | <info> | ||
| 80 | <title>Perl Elements to Avoid</title> | ||
| 81 | </info> | ||
| 82 | <body> | ||
| 83 | <preface xml:id="intro"> | ||
| 84 | <info> | ||
| 85 | <title>Introduction</title> | ||
| 86 | </info> | ||
| 87 | |||
| 88 | <p> | ||
| 89 | Often when people ask for help with Perl code, they show | ||
| 90 | Perl code that | ||
| 91 | suffers from many bad or outdated <b>elements</b>. | ||
| 92 | </p> | ||
| 93 | |||
| 94 | <p> | ||
| 95 | <strong>Note:</strong> Please don't think this advice is | ||
| 96 | meant as gospel. I tried to avoid | ||
| 97 | <a xlink:href="http://bikeshed.com/">colour of | ||
| 98 | the bike shed arguments</a>), but some of the advice here | ||
| 99 | may still be controversial. | ||
| 100 | </p> | ||
| 101 | </preface> | ||
| 102 | <section xml:id="bad-elements"> | ||
| 103 | <info> | ||
| 104 | <title>The List of Bad Elements</title> | ||
| 105 | </info> | ||
| 106 | <item xml:id="no-indentation"> | ||
| 107 | <info> | ||
| 108 | <title>No Indentation</title> | ||
| 109 | </info> | ||
| 110 | <p> | ||
| 111 | <a | ||
| 112 | xlink:href="http://en.wikipedia.org/wiki/Indent_style">Indentation</a> | ||
| 113 | means that the contents of every block are promoted from their | ||
| 114 | containing environment by using a shift of some space. This | ||
| 115 | makes the code easier to read and follow. | ||
| 116 | </p> | ||
| 117 | |||
| 118 | <p> | ||
| 119 | You can look into <cpan_self_dist d="Perl-Tidy" /> from | ||
| 120 | CPAN for more information. | ||
| 121 | </p> | ||
| 122 | </section> | ||
| 123 | <section xml:id="sources_of_advice"> | ||
| 124 | <info> | ||
| 125 | <title>Sources of This Advice</title> | ||
| 126 | </info> | ||
| 127 | |||
| 128 | <p> | ||
| 129 | This is a short list of the sources from which this advice was | ||
| 130 | taken which | ||
| 131 | also contains material for further reading: | ||
| 132 | </p> | ||
| 133 | |||
| 134 | <ol> | ||
| 135 | |||
| 136 | <li> | ||
| 137 | <p> | ||
| 138 | <a xlink:href="$(ROOT)/books/advanced/#pbp">The | ||
| 139 | Book "Perl Best Practices"</a> by Damian Conway - contains a lot of good | ||
| 140 | advice and food for thought, but sometimes should be deviated from. | ||
| 141 | Also see the | ||
| 142 | <a xlink:href="https://www.socialtext.net/perl5/index.cgi?pbp_module_recommendation_commentary">"PBP | ||
| 143 | Module Recommendation Commentary"</a> on the Perl 5 Wiki. | ||
| 144 | </p> | ||
| 145 | </li> | ||
| 146 | |||
| 147 | <li> | ||
| 148 | <p> | ||
| 149 | <a xlink:href="https://www.socialtext.net/perl5/index.cgi?ancient_perl">"Ancient | ||
| 150 | Perl"</a> on the Perl 5 Wiki. | ||
| 151 | </p> | ||
| 152 | </li> | ||
| 153 | |||
| 154 | <li> | ||
| 155 | <p> | ||
| 156 | <a xlink:href="http://modernperlbooks.com/">chromatic's "Modern Perl" Book and | ||
| 157 | Blog</a> | ||
| 158 | </p> | ||
| 159 | </li> | ||
| 160 | |||
| 161 | <li> | ||
| 162 | <p> | ||
| 163 | The book <a xlink:href="http://www.refactoring.com/"><i>Refactoring</i> by Martin | ||
| 164 | Fowler</a> - not particularly about Perl, but still useful. | ||
| 165 | </p> | ||
| 166 | </li> | ||
| 167 | |||
| 168 | <li> | ||
| 169 | <p> | ||
| 170 | The book | ||
| 171 | <a xlink:href="http://pragprog.com/book/tpp/the-pragmatic-programmer"><i>The Pragmatic | ||
| 172 | Programmer: From Journeyman to Master</i></a> - also not particularly about | ||
| 173 | Perl, and I found it somewhat disappointing, but it is an informative book. | ||
| 174 | </p> | ||
| 175 | </li> | ||
| 176 | |||
| 177 | <li> | ||
| 178 | <p> | ||
| 179 | Advice given by people on <a xlink:href="$(ROOT)/irc/#freenode">Freenode's #perl | ||
| 180 | channel</a>, on the Perl Beginners mailing list, and on other Perl forums. | ||
| 181 | </p> | ||
| 182 | </li> | ||
| 183 | |||
| 184 | </ol> | ||
| 185 | |||
| 186 | </section> | ||
| 187 | </body> | ||
| 188 | </document> | ||
| 189 | |||
| 190 | =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan | ||
| 191 | |||
| 192 | =head1 SUPPORT | ||
| 193 | |||
| 194 | =head2 Websites | ||
| 195 | |||
| 196 | The following websites have more information about this module, and may be of help to you. As always, | ||
| 197 | in addition to those websites please use your favorite search engine to discover more resources. | ||
| 198 | |||
| 199 | =over 4 | ||
| 200 | |||
| 201 | =item * | ||
| 202 | |||
| 203 | MetaCPAN | ||
| 204 | |||
| 205 | A modern, open-source CPAN search engine, useful to view POD in HTML format. | ||
| 206 | |||
| 207 | L<https://metacpan.org/release/XML-Grammar-Vered> | ||
| 208 | |||
| 209 | =item * | ||
| 210 | |||
| 211 | RT: CPAN's Bug Tracker | ||
| 212 | |||
| 213 | The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN. | ||
| 214 | |||
| 215 | L<https://rt.cpan.org/Public/Dist/Display.html?Name=XML-Grammar-Vered> | ||
| 216 | |||
| 217 | =item * | ||
| 218 | |||
| 219 | CPANTS | ||
| 220 | |||
| 221 | The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution. | ||
| 222 | |||
| 223 | L<http://cpants.cpanauthors.org/dist/XML-Grammar-Vered> | ||
| 224 | |||
| 225 | =item * | ||
| 226 | |||
| 227 | CPAN Testers | ||
| 228 | |||
| 229 | The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions. | ||
| 230 | |||
| 231 | L<http://www.cpantesters.org/distro/X/XML-Grammar-Vered> | ||
| 232 | |||
| 233 | =item * | ||
| 234 | |||
| 235 | CPAN Testers Matrix | ||
| 236 | |||
| 237 | The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. | ||
| 238 | |||
| 239 | L<http://matrix.cpantesters.org/?dist=XML-Grammar-Vered> | ||
| 240 | |||
| 241 | =item * | ||
| 242 | |||
| 243 | CPAN Testers Dependencies | ||
| 244 | |||
| 245 | The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. | ||
| 246 | |||
| 247 | L<http://deps.cpantesters.org/?module=XML::Grammar::Vered> | ||
| 248 | |||
| 249 | =back | ||
| 250 | |||
| 251 | =head2 Bugs / Feature Requests | ||
| 252 | |||
| 253 | Please report any bugs or feature requests by email to C<bug-xml-grammar-vered at rt.cpan.org>, or through | ||
| 254 | the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=XML-Grammar-Vered>. You will be automatically notified of any | ||
| 255 | progress on the request by the system. | ||
| 256 | |||
| 257 | =head2 Source Code | ||
| 258 | |||
| 259 | The code is open to the world, and available for you to hack on. Please feel free to browse it and play | ||
| 260 | with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull | ||
| 261 | from your repository :) | ||
| 262 | |||
| 263 | L<https://github.com/shlomif/XML-Grammar-Vered> | ||
| 264 | |||
| 265 | git clone git://github.com/shlomif/XML-Grammar-Vered.git | ||
| 266 | |||
| 267 | =head1 AUTHOR | ||
| 268 | |||
| 269 | Shlomi Fish <shlomif@cpan.org> | ||
| 270 | |||
| 271 | =head1 BUGS | ||
| 272 | |||
| 273 | Please report any bugs or feature requests on the bugtracker website | ||
| 274 | L<https://github.com/shlomif/XML-Grammar-Vered/issues> | ||
| 275 | |||
| 276 | When submitting a bug or request, please include a test-file or a | ||
| 277 | patch to an existing test-file that illustrates the bug or desired | ||
| 278 | feature. | ||
| 279 | |||
| 280 | =head1 COPYRIGHT AND LICENSE | ||
| 281 | |||
| 282 | This software is Copyright (c) 2013 by Shlomi Fish. | ||
| 283 | |||
| 284 | This is free software, licensed under: | ||
| 285 | |||
| 286 | The MIT (X11) License | ||
| 287 | |||
| 288 | =cut | ||