| 1 | # $Id: XSH2.pm,v 2.3 2007-01-02 22:03:23 pajas Exp $ | ||
| 2 | |||
| 3 | package XML::XSH2; | ||
| 4 | |||
| 5 | 8 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 8 | ▶ | use vars qw(@EXPORT_OK @EXPORT @ISA $VERSION); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 8 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 8 | $VERSION='2.2.10'; # VERSION TEMPLATE | |
| 10 | 8 | @ISA = qw(Exporter); | |
| 11 | 8 | @EXPORT = qw(&xsh); | |
| 12 | 8 | @EXPORT_OK = @XML::XSH2::Functions::EXPORT_OK; | |
| 13 | 8 | *xshNS = \'http://xsh.sourceforge.net/xsh/'; | |
| 14 | |||
| 15 | 8 | ▶ | use Exporter; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 8 | ▶ | use XML::XSH2::Functions qw(:default); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 8 | ▶ | use XML::XSH2::Completion; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | |||
| 19 | } | ||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | 8 | 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<XSH> | ||
| 63 | and on L<http://xsh.sourceforge.net/documentation.html>. | ||
| 64 | |||
| 65 | The distribution package of XML::XSH2 module includes XSH shell | ||
| 66 | interpreter called C<xsh> (see L<xsh>). To use it interactively, run | ||
| 67 | C<xsh -i>. | ||
| 68 | |||
| 69 | =head2 C<xsh_init> | ||
| 70 | |||
| 71 | Initialize the XSH language parser and interpreter. | ||
| 72 | |||
| 73 | =head2 C<xsh> | ||
| 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<xsh>, L<XSH2>, L<XML::XSH2::Compile>, L<XML::LibXML>, L<XML::XUpdate> | ||
| 85 | |||
| 86 | =cut | ||