| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | # $Id: XSH2.pm,v 2.3 2007-01-02 22:03:23 pajas Exp $ | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | package XML::XSH2; | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 8 |  |  | 8 |  | 109978 | use strict; | 
|  | 8 |  |  |  |  | 70 |  | 
|  | 8 |  |  |  |  | 389 |  | 
| 6 | 8 |  |  | 8 |  | 47 | use vars qw(@EXPORT_OK @EXPORT @ISA $VERSION); | 
|  | 8 |  |  |  |  | 17 |  | 
|  | 8 |  |  |  |  | 912 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 0 |  |  |  |  |  | BEGIN { | 
| 9 | 8 |  |  | 8 |  | 29 | $VERSION='2.2.9'; # VERSION TEMPLATE | 
| 10 | 8 |  |  |  |  | 163 | @ISA       = qw(Exporter); | 
| 11 | 8 |  |  |  |  | 38 | @EXPORT = qw(&xsh); | 
| 12 | 8 |  |  |  |  | 71 | @EXPORT_OK = @XML::XSH2::Functions::EXPORT_OK; | 
| 13 | 8 |  |  |  |  | 317 | *xshNS = \'http://xsh.sourceforge.net/xsh/'; | 
| 14 |  |  |  |  |  |  |  | 
| 15 | 8 |  |  | 8 |  | 62 | use Exporter; | 
|  | 8 |  |  |  |  | 37 |  | 
|  | 8 |  |  |  |  | 411 |  | 
| 16 | 8 |  |  | 8 |  | 7995 | use XML::XSH2::Functions qw(:default); | 
|  | 8 |  |  |  |  | 25 |  | 
|  | 8 |  |  |  |  | 3050 |  | 
| 17 | 8 |  |  | 8 |  | 3884 | use XML::XSH2::Completion; | 
|  | 8 |  |  |  |  | 30 |  | 
|  | 8 |  |  |  |  | 319 |  | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | } | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | 1; | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | =head1 NAME | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | XML::XSH2 - A powerfull scripting language/shell for XPath-based editing of XML | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | use XML::XSH2; | 
| 32 |  |  |  |  |  |  | xsh(<<'__XSH__'); | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | # ... XSH Language commands (example borrowed from Kip Hampton's article) ... | 
| 35 |  |  |  |  |  |  | $sources := open "perl_channels.xml";   # open a document from file | 
| 36 |  |  |  |  |  |  | $merge := create "news-items";            # create a new document | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | foreach $sources//rss-url {         # traverse the sources document | 
| 39 |  |  |  |  |  |  | my $src := open @href;          # load the URL given by @href attribute | 
| 40 |  |  |  |  |  |  | map { $_ = lc($_) } //*;        # lowercase all tag names | 
| 41 |  |  |  |  |  |  | xcopy $src//item                # copy all items from the src document | 
| 42 |  |  |  |  |  |  | into $merge/news-items[1];   # into the news-items element in merge document | 
| 43 |  |  |  |  |  |  | close $src;                     # close src document (not mandatory) | 
| 44 |  |  |  |  |  |  | }; | 
| 45 |  |  |  |  |  |  | close $sources; | 
| 46 |  |  |  |  |  |  | save --file "files/headlines.xml" $merge; # save the resulting merge document | 
| 47 |  |  |  |  |  |  | close $merge; | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | __XSH__ | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | =head1 REQUIRES | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | XML::LibXML, XML::XUpdate::LibXML | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | =head1 EXPORTS | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | xsh() | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | This module implements XSH sripting language. XSH stands for XML | 
| 62 |  |  |  |  |  |  | (editing) SHell. XSH language is documented in L | 
| 63 |  |  |  |  |  |  | and on L. | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | The distribution package of XML::XSH2 module includes XSH shell | 
| 66 |  |  |  |  |  |  | interpreter called C (see L). To use it interactively, run | 
| 67 |  |  |  |  |  |  | C. | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | =head2 C | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | Initialize the XSH language parser and interpreter. | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | =head2 C | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | Execute commands in XSH language. | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | =head1 AUTHORS | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | Petr Pajas, pajas@matfyz.cz | 
| 80 |  |  |  |  |  |  | E. Choroba, choroba@matfyz.cz | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | L, L, L, L, L | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | =cut |