r10515 - in /branches/upstream/libxml-node-perl: ./ current/

vdanjean at users.alioth.debian.org vdanjean at users.alioth.debian.org
Sat Dec 1 12:33:50 UTC 2007


Author: vdanjean
Date: Sat Dec  1 12:33:50 2007
New Revision: 10515

URL: http://svn.debian.org/wsvn/?sc=1&rev=10515
Log:
[svn-inject] Installing original source of libxml-node-perl

Added:
    branches/upstream/libxml-node-perl/
    branches/upstream/libxml-node-perl/current/
    branches/upstream/libxml-node-perl/current/Changes
    branches/upstream/libxml-node-perl/current/MANIFEST
    branches/upstream/libxml-node-perl/current/Makefile.PL
    branches/upstream/libxml-node-perl/current/Node.pm
    branches/upstream/libxml-node-perl/current/README
    branches/upstream/libxml-node-perl/current/XML-Node.sgml
    branches/upstream/libxml-node-perl/current/foo.xml
    branches/upstream/libxml-node-perl/current/orders.xml
    branches/upstream/libxml-node-perl/current/parse-foo.pl
    branches/upstream/libxml-node-perl/current/parse-orders.pl
    branches/upstream/libxml-node-perl/current/parse-testsuite.pl
    branches/upstream/libxml-node-perl/current/test.pl
    branches/upstream/libxml-node-perl/current/test.xml

Added: branches/upstream/libxml-node-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-node-perl/current/Changes?rev=10515&op=file
==============================================================================
--- branches/upstream/libxml-node-perl/current/Changes (added)
+++ branches/upstream/libxml-node-perl/current/Changes Sat Dec  1 12:33:50 2007
@@ -1,0 +1,19 @@
+Revision history for Perl extension XML::Node
+0.11  Dec 10 Mon 2:07:06 2001
+	- added support for relative paths         
+	- rename XML::Node.sgml to XML-Node.sgml so that Windows people can 
+          unzip the package.
+0.10  Mar 13 Mon 2:07:06
+	- Bug fixs
+	- Add suport for IO::Handle
+        *** Note that old parse() is replaced by parsefile() ***
+0.09  Mon Nov 15 11:29:53 PST 1999
+	- Add support for attributes
+0.06  Thu Nov  4 17:26:25 PST 1999
+	- Change to object style.
+	- Allow multiple instances running simultaneously
+0.04  Thu Oct 20 09:00:00 1999
+	- Getting ready to upload to CPAN
+0.01  Thu Oct  7 23:23:33 1999
+	- original version; 
+

Added: branches/upstream/libxml-node-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-node-perl/current/MANIFEST?rev=10515&op=file
==============================================================================
--- branches/upstream/libxml-node-perl/current/MANIFEST (added)
+++ branches/upstream/libxml-node-perl/current/MANIFEST Sat Dec  1 12:33:50 2007
@@ -1,0 +1,13 @@
+README
+Changes
+MANIFEST
+Makefile.PL
+Node.pm
+test.pl
+parse-orders.pl
+parse-testsuite.pl
+parse-foo.pl
+foo.xml
+orders.xml
+test.xml
+XML-Node.sgml

Added: branches/upstream/libxml-node-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-node-perl/current/Makefile.PL?rev=10515&op=file
==============================================================================
--- branches/upstream/libxml-node-perl/current/Makefile.PL (added)
+++ branches/upstream/libxml-node-perl/current/Makefile.PL Sat Dec  1 12:33:50 2007
@@ -1,0 +1,7 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+	      NAME      => 'XML::Node',
+#	      MAN3PODS  => 'Node.pm',
+	      VERSION_FROM => 'Node.pm',
+	      );

Added: branches/upstream/libxml-node-perl/current/Node.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-node-perl/current/Node.pm?rev=10515&op=file
==============================================================================
--- branches/upstream/libxml-node-perl/current/Node.pm (added)
+++ branches/upstream/libxml-node-perl/current/Node.pm Sat Dec  1 12:33:50 2007
@@ -1,0 +1,369 @@
+# Copyright (c)  1999 Chang  Liu 
+# All rights  reserved.  
+#
+# This program is  free software; you can redistribute  it and/or modify
+# it under the same terms as Perl itself.
+
+
+package XML::Node;
+
+#use strict;
+#use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
+
+=head1 NAME
+
+XML::Node - Node-based XML parsing: an simplified interface to XML::Parser
+
+=head1 SYNOPSIS
+
+ use XML::Node;
+
+ $xml_node = new XML::Node;
+ $xml_node->register( $nodetype, $callback_type => \&callback_function );
+ $xml_node->register( $nodetype, $callback_type => \$variable );
+    
+ open(FOO, 'xmlgenerator |');
+ $p3->parse(*FOO);
+ close(FOO);
+
+ $xml_node->parsefile( $xml_filename );
+
+=head1 DESCRIPTION
+
+If you are only interested in processing certain nodes in an XML file, this 
+module can help you simplify your Perl scripts significantly.
+
+The XML::Node module allows you to register callback functions or variables for 
+any  XML node. If you register a call back function, it will be called when
+the node of the type you specified are encountered. If you register a variable, 
+the content of a XML node will be appended to that variable automatically. 
+
+Subroutine register accepts both absolute and relative node registrations.
+
+Here is an example of absolute path registration: 
+
+ 1. register(">TestCase>Name", "start" => \&handle_TestCase_Name_start);
+
+Here are examples of single node name registration:
+
+ 2. register( "Name", "start" => \&handle_Name_start);
+ 3. register( "Name", "end"   => \&handle_Name_end);
+ 4. register( "Name", "char"  => \&handle_Name_char);
+
+Here is an example of attribute registration:
+
+ 5. register(">TestCase:Author", "attr" => \$testcase_author);
+
+Abosolute path trigger condition is recommended because a "Name" tage could appear in different
+places and stands for differe names. 
+
+Example:
+
+  1  <Testcase>
+  2     <Name>Something</Name>
+  3     <Oracle>
+  4         <Name>Something</Name>
+  5     </Oracle>
+  6  </Testcase>
+
+Statement 1 causes &handle_TestCase_Name_start to be called when parsing Line 2. Statements 2,3,4 cause the three handler subroutines to be called when parsing both Line 2 and Line 4.
+
+This module uses XML::Parser.
+
+=head1 EXAMPLE
+
+Examples "test.pl" and "parse_orders.pl" come with this perl module.
+
+=head1 SEE ALSO
+
+XML::Parser
+
+=head1 NOTE
+
+When you register a variable, XML::Node appends strings found to that variable. So please be sure to clear that variable before it is used again.
+
+=head1 AUTHORS
+
+Chang Liu <liu at ics.uci.edu>
+
+=head1 LAST MODIFIED
+
+$Date: 2001/12/10 11:38:28 $
+
+=cut
+
+
+use Exporter;
+$VERSION = "0.11";
+ at ISA = ('Exporter');
+ at EXPORT = qw (&register &parse &parsefile);
+
+
+use XML::Parser;
+use Carp;
+
+
+if ($ENV{DEBUG}) {
+    print "DEBUG:XML::Node.pm VERSION $VERSION\n";
+}
+
+my $instance = 0;
+my @selves = ();
+my $myinstance;
+
+sub new{
+    my $class = shift;
+    
+    my $self = {
+	INSTANCE       => $instance,
+	START_HANDLERS => {},
+	END_HANDLERS   => {},
+	CHAR_HANDLERS  => {},
+       	ATTR_HANDLERS  => {},
+	CURRENT_TAG    => "",
+	CURRENT_PATH   => "",
+    };
+    bless $self, $class;
+    $selves[$instance++] = $self;
+    return $self;
+}
+
+sub register
+{
+    $self = shift or croak "XML::Node --self is expected as THE first parameter \&register.\n";
+    my $node = shift or croak "XML::Node --a node path is expected as arg1 in \&register.\n";
+    my $type = shift or croak "XML::Node --node type is expected as arg2 in \&register.\n";
+    my $handler = shift or croak "XML::Node --a handler is expected as arg3 in \&register.\n";
+    if ($type eq "start") {
+	$self->{START_HANDLERS}->{$node} = $handler;
+    } elsif ($type eq "end") {
+	$self->{END_HANDLERS}->{$node} = $handler;
+    } elsif ($type eq "char") { 
+	$self->{CHAR_HANDLERS}->{$node} = $handler;
+    } elsif ($type eq "attr") { 
+	$self->{ATTR_HANDLERS}->{$node} = $handler;
+    } else {
+	croak "XML::Node --unknown handler type $type for node $node\n";
+    }
+}
+
+
+sub parsefile
+{
+    $self = shift or croak "XML::Node --self is expected as THE first parameter \&register.\n";
+    my $xml_file = shift or croak "XML::Node --an XML filename is expected in \&parse.\n";
+
+    $myinstance = $self->{INSTANCE};
+    carp "XML::Node - invoking parser [$myinstance]" if $ENV{DEBUG};
+
+my $my_handlers = qq {
+sub handle_start_$myinstance
+{
+    &handle_start($myinstance, \@_);
+}
+sub handle_end_$myinstance
+{
+    &handle_end($myinstance, \@_);
+}
+sub handle_char_$myinstance
+{
+    &handle_char($myinstance, \@_);
+}
+\$XML::Node::parser = new XML::Parser(Handlers => { Start => \\& handle_start_$myinstance,
+					End =>   \\& handle_end_$myinstance,
+					Char =>  \\& handle_char_$myinstance } );
+
+};
+   #carp "[[[[[[[[[[[[[[[[$my_handlers]]]]]]]]]]]]]]";
+    eval ($my_handlers);
+    $parser->parsefile("$xml_file");
+}
+
+sub parse
+{
+    $self = shift or croak "XML::Node --self is expected as THE first parameter \&register.\n";
+
+    $myinstance = $self->{INSTANCE};
+    carp "XML::Node - invoking parser [$myinstance]" if $ENV{DEBUG};
+
+my $my_handlers = qq {
+sub handle_start_$myinstance
+{
+    &handle_start($myinstance, \@_);
+}
+sub handle_end_$myinstance
+{
+    &handle_end($myinstance, \@_);
+}
+sub handle_char_$myinstance
+{
+    &handle_char($myinstance, \@_);
+}
+\$XML::Node::parser = new XML::Parser(Handlers => { Start => \\& handle_start_$myinstance,
+					End =>   \\& handle_end_$myinstance,
+					Char =>  \\& handle_char_$myinstance } );
+
+};
+   #carp "[[[[[[[[[[[[[[[[$my_handlers]]]]]]]]]]]]]]";
+    eval ($my_handlers);
+    $parser->parse(shift);
+}
+
+sub handle_start
+{
+    my $myinstance = shift;
+    my $p = shift;
+    my $element = shift;
+
+    
+    my $current_path = $selves[$myinstance]->{CURRENT_PATH} = 
+    	$selves[$myinstance]->{CURRENT_PATH} . ">" .  $element;
+    my $current_tag = $selves[$myinstance]->{CURRENT_TAG} = $element;
+
+    my $attr;
+    my $value;
+
+#    carp("handle_start called [$myinstance] [$element] [$current_path]\n");
+    
+    while (defined ($attr = shift ) ) {
+	if (! defined ($value = shift)) {
+	    croak ("value for attribute [$attr] of element [$element] is not returned by XML::Parser\n");
+	}
+#	carp("Attribute [$attr] of element [$element] found with value [$value] attr_path:[$attr_path]\n");
+        my @array = split(/>/, $current_path);
+        my $current_relative_path = "$current_tag:$attr";
+        my $i;
+	if ($selves[$myinstance]->{ATTR_HANDLERS}->{$current_relative_path}) {
+	    handle($p, $value, $selves[$myinstance]->{ATTR_HANDLERS}->{$current_relative_path});
+	}
+        for ($i=$#array-1;$i>=1;$i--)
+        { # call all relative paths 
+    	    $current_relative_path = $array[$i] . ">" . $current_relative_path;
+  	    if ($selves[$myinstance]->{ATTR_HANDLERS}->{$current_relative_path}) {
+	        handle($p, $value, $selves[$myinstance]->{ATTR_HANDLERS}->{$current_relative_path});
+	    }
+    	}
+	my $attr_path = "$current_path:$attr";
+	if ($selves[$myinstance]->{ATTR_HANDLERS}->{$attr_path}) {
+	    handle($p, $value, $selves[$myinstance]->{ATTR_HANDLERS}->{$attr_path});
+	}
+    }
+
+    my @array = split(/>/, $current_path);
+    my $current_relative_path = $current_tag;
+    my $i;
+
+    if ($selves[$myinstance]->{START_HANDLERS}->{$current_tag}) {
+	handle($p, $element, $selves[$myinstance]->{START_HANDLERS}->{$current_tag});
+    }
+#carp("--Begin loop\n");
+    for ($i=$#array-1;$i>=1;$i--)
+    { # call all relative paths 
+	$current_relative_path = $array[$i] . ">" . $current_relative_path;
+#carp("Array size is $#array, \$i is $i, current_relative_path is $current_relative_path\n");
+        if ($selves[$myinstance]->{START_HANDLERS}->{$current_relative_path}) {
+    	    handle($p, $element, $selves[$myinstance]->{START_HANDLERS}->{$current_relative_path});
+        }
+    }
+#carp("--End loop\n");
+    if ($selves[$myinstance]->{START_HANDLERS}->{$current_path}) {
+	handle($p, $element, $selves[$myinstance]->{START_HANDLERS}->{$current_path});
+    }
+}
+
+sub handle_end
+{
+    my $myinstance = shift;
+    my $p = shift;
+    my $element = shift;
+    my $current_path = $selves[$myinstance]->{CURRENT_PATH};
+
+#    carp("handle_end called [$myinstance] [$element]\n");
+    
+    $selves[$myinstance]->{CURRENT_TAG} = $element;
+
+    my @array = split(/>/, $current_path);
+    my $current_relative_path = $element;
+    my $i;
+    
+    if ($selves[$myinstance]->{END_HANDLERS}->{$selves[$myinstance]->{CURRENT_TAG}}) {
+	handle($p, $element, $selves[$myinstance]->{END_HANDLERS}->{$selves[$myinstance]->{CURRENT_TAG}});
+    }
+    for ($i=$#array-1;$i>=1;$i--)
+    { # call all relative paths 
+	$current_relative_path = $array[$i] . ">" . $current_relative_path;
+#carp("Array size is $#array, \$i is $i, current_relative_path is $current_relative_path\n");
+        if ($selves[$myinstance]->{END_HANDLERS}->{$current_relative_path}) {
+    	    handle($p, $element, $selves[$myinstance]->{END_HANDLERS}->{$current_relative_path});
+        }
+    }
+    if ($selves[$myinstance]->{END_HANDLERS}->{$selves[$myinstance]->{CURRENT_PATH}}) {
+	handle($p, $element, $selves[$myinstance]->{END_HANDLERS}->{$selves[$myinstance]->{CURRENT_PATH}});
+    } 
+    
+    $selves[$myinstance]->{CURRENT_PATH} =~ /(.*)>/;
+    $selves[$myinstance]->{CURRENT_PATH} = $1;
+    $selves[$myinstance]->{CURRENT_TAG}  = $';
+    if ($element ne $selves[$myinstance]->{CURRENT_TAG}) {
+	carp "start-tag <$selves[$myinstance]->{CURRENT_TAG}> doesn't match end-tag <$element>. Is this XML file well-formed?\n";
+    }
+    $selves[$myinstance]->{CURRENT_PATH} =~ /(.*)>/;
+    $selves[$myinstance]->{CURRENT_TAG}  = $';
+}
+
+sub handle_char
+{
+    my $myinstance = shift;
+    my $p = shift;
+    my $element = shift;
+    my $current_path = $selves[$myinstance]->{CURRENT_PATH};
+    
+#    carp("handle_char called [$myinstance] [$element]\n");
+
+    my @array = split(/>/, $current_path);
+    my $current_relative_path = $element;
+    my $i;
+
+    if ($selves[$myinstance]->{CHAR_HANDLERS}->{$selves[$myinstance]->{CURRENT_TAG}}) {
+	handle($p, $element, $selves[$myinstance]->{CHAR_HANDLERS}->{$selves[$myinstance]->{CURRENT_TAG}});
+    }
+    for ($i=$#array-1;$i>=1;$i--)
+    { # call all relative paths 
+	$current_relative_path = $array[$i] . ">" . $current_relative_path;
+        if ($selves[$myinstance]->{CHAR_HANDLERS}->{$current_relative_path}) {
+    	    handle($p, $element, $selves[$myinstance]->{CHAR_HANDLERS}->{$current_relative_path});
+        }
+    }
+    if ($selves[$myinstance]->{CHAR_HANDLERS}->{$selves[$myinstance]->{CURRENT_PATH}}) {
+	handle($p, $element, $selves[$myinstance]->{CHAR_HANDLERS}->{$selves[$myinstance]->{CURRENT_PATH}});
+    }
+}
+
+sub handle
+{
+    my $p = shift;
+    my $element = shift;
+    my $handler = shift;
+
+    my $handler_type = ref($handler);
+    if ($handler_type eq "CODE") {
+	&$handler($p,$element);  # call the handler function
+    } elsif ($handler_type eq "SCALAR")  {
+#	chomp($element);
+#	$element =~ /^(\s*)/;
+#	$element = $';
+#	$element =~ /(\s*)$/;
+#	$element = $`;
+	if (! defined $$handler) {
+	    $$handler = "";
+	    #carp ("XML::Node - SCALAR handler undefined when processing [$element]");
+	}
+	$$handler = $$handler . $element;  #append the content to the handler variable
+    } else {
+	carp "XML::Node -unknown handler type [$handler_type]\n";
+	exit;
+    }
+}
+
+
+1;

Added: branches/upstream/libxml-node-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-node-perl/current/README?rev=10515&op=file
==============================================================================
--- branches/upstream/libxml-node-perl/current/README (added)
+++ branches/upstream/libxml-node-perl/current/README Sat Dec  1 12:33:50 2007
@@ -1,0 +1,127 @@
+			XML::Node Version 0.11
+
+Here is a quick but complete example to show you how XML::Node promises
+to keep your XML processing scripts short and clear.
+----------  orders.xml  ----------------------------------------------
+<Orders>
+  <Order ID="0008">
+    <Item>A Book</Item>
+    <Quantity>1</Quantity>
+    <TagsThatIDontCare>Something</TagsThatIDontCare>
+   </Order>
+   <TagsThatIDontCare>Blah Blah</TagsThatIDontCare>
+</Orders>
+
+----------  parse-orders.pl ------------------------------------------
+use XML::Node;
+
+my $item = "";
+my $quantity = "";
+my $id = "";
+
+$p = XML::Node->new();
+
+$p->register(">Orders>Order:ID","char" => \$item);
+$p->register(">Orders>Order>Item","char" => \$item);
+$p->register(">Orders>Order>Quantity","char" => \$quantity);
+$p->register(">Orders>Order","end" => \&handle_order_end);
+
+print "Processing file [orders.xml]...\n";
+$p->parsefile("orders.xml");
+
+sub handle_order_end
+{
+    print "Found order [$id] -- Item: [$item] Quantity: [$quantity]\n";
+    $id="";
+    $item = "";
+    $quantity = "";
+}
+
+---------------------------------------------------------------------
+Copyright (c)  1999,2000,2001 Chang  Liu 
+All rights  reserved.  
+
+This program is  free software; you can redistribute  it and/or modify
+it under the same terms as Perl itself.
+
+This is  a Perl  extension interface to  XML::Parser.  It  requires at
+least version 5.004 of perl.  The documentation for this extension can
+be  found in  pod  format in  the file Node.pm. The 'perldoc' program,
+provided  with  the  perl  distribution,  can be  used  to  view  this
+documentation.
+
+The  purpose  of   this  module  is  to  simplify   interface  of  XML
+parser. Instead of worrying about "start", "end", and "char" callbacks
+of every single XML node, you can  simply say that you only want to be
+notified  when  a  path,  such  as ">TestCase>Name",  is  found.  Path
+">TestCase>Name" corresponds to XML nodes:
+  <TestCase>
+    ...
+    <Name>Something</Name>
+    ...
+  </TestCase>
+
+Using XML::Node, you can easily ignore the parts of XML files that you
+are not interested  in.  Another feature of XML::Node  is that you can
+register a variable instead  of a callback function. The corresponding
+string  found in a  XML file  will be  automatically appended  to your
+variable. This  way, you don't have  to write a  callback function for
+this type of simple handling. Here's an example:
+
+  my $testcase_name = "";
+  register(">TestCase>Name","char" => \$testcase_name);
+
+
+---------------------------------------------------------------------
+To  install this  module, cd  to  the directory  that contains  this
+README file and type the following:
+
+	perl Makefile.PL
+
+Alternatively, if  you plan to install XML::Node  somewhere other than
+your  system's perl library  directory.  You  can type  something like
+this:
+
+	perl Makefile.PL PREFIX=/home/me/perl INSTALLDIRS=perl
+
+Then to build you run make.
+
+	make
+
+You can then test the module by typing:
+
+	make test
+
+There are some sample utilities in the samples directory along with an
+xml form  of the XML  specification to test  them on. You may  need to
+change  the  '#!' line  at  the  top of  these  utilities  to what  is
+appropriate for your system. If  you're going to play around with them
+prior to installing  the module, you would need to  add the blib paths
+to your perl  search path, like this (assuming  your current directory
+is samples):
+
+    perl -I../blib/lib -I../blib/arch test.pl
+
+or set your PERLLIB environment variable.
+
+If you have write access to the installation directories, you may then
+install by typing:
+
+    make install
+
+After this, you  may use "man XML::Node" to view the  man page of this
+module.
+
+
+---------------------------------------------------------------------
+When testing the package, make sure "make install" is called every 
+time after "Node.pm" is modified.
+---------------------------------------------------------------------
+To rebuild the package: 
+	edit MANIFEST
+	perl Makefile.PL
+	make dist or nmake dist (make sure tar and gzip are on path.)
+
+  --Chang Liu (liu at ics.uci.edu | changliu at acm.org)
+
+

Added: branches/upstream/libxml-node-perl/current/XML-Node.sgml
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-node-perl/current/XML-Node.sgml?rev=10515&op=file
==============================================================================
--- branches/upstream/libxml-node-perl/current/XML-Node.sgml (added)
+++ branches/upstream/libxml-node-perl/current/XML-Node.sgml Sat Dec  1 12:33:50 2007
@@ -1,0 +1,102 @@
+<?xml version='1.0'?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
+<article id="index">
+<artheader>
+  <author><firstname>Chang</><surname>Liu</></author>
+  <pubdate>Nov 1999</pubdate>
+  <title>Perl Module XML::Node</title>
+  <revhistory>
+     <revision>
+        <revnumber>0.09</revnumber>
+        <date>15 Nov 1999</date>
+        <revremark>--Add support to attributes</revremark>
+     </revision>
+     <revision>
+        <revnumber>0.06</revnumber>
+        <date>4 Nov 1999</date>
+        <revremark>--Change to an object class</revremark>
+     </revision>
+     <revision>
+        <revnumber>0.04</revnumber>
+        <date>20 Oct 1999</date>
+        <revremark>--The first version that's submitted to CPAN.</revremark>
+     </revision>
+  </revhistory>
+</artheader>
+
+<sect1>
+<title>XML::Node</title>
+<sect2 id="overview">
+<title>Overview</title>
+<para>
+XML::Node is for those who use Perl to process XML files. XML::Node is built on top of XML::Parser and provides a simplified programming interface. XML::Node users can register callback sub-routines or variables to specific type of XML nodes. The values of the specified XML nodes are automatically copied to the corresponding variables. When specified XML tags are found, registered callback sub-routines are called. XML::Node is a shortcut to XML::Parser if you don't care much about details of XML files.
+</para>
+
+<para>
+Here is an example. This XML file contains order information:
+
+<example id="xml">
+<title>orders.xml</title>
+<programlisting role="XML">
+<![CDATA[
+<Orders>
+  <Order>
+    <Item>A Book</Item>
+    <Quantity>1</Quantity>
+    <TagsThatIDontCare>Something</TagsThatIDontCare>
+   </Order>
+   <TagsThatIDontCare>Blah Blah</TagsThatIDontCare>
+</Orders>
+]]>
+</programlisting>
+</example>
+
+This simple Perl script can parse the XML file and print out all the orders. 
+
+<example id="perl" label="perl">
+<title>parse_orders.pl</title>
+<programlisting role="Perl">
+<![CDATA[
+use XML::Node;
+
+my $item = "";
+my $quantity = "";
+
+$p = XML::Node->new();
+
+$p->register(">Orders>Order>Item","char" => \$item);
+$p->register(">Orders>Order>Quantity","char" => \$quantity);
+$p->register(">Orders>Order","end" => \&handle_order_end);
+
+print "Processing file [orders.xml]...\n";
+$p->parsefile("orders.xml");
+
+sub handle_order_end
+{
+    print "Found order -- Item: [$item] Quantity: [$quantity]\n";
+    $item = "";
+    $quantity = "";
+}
+]]>
+</programlisting>
+</example>
+
+</para>
+</sect2>
+
+<sect2 id="download">
+<title>Download</title>
+<para>
+The XML::Node module can be found at <ulink url="http://belmont-shores.ics.uci.edu/pub">http://belmont-shores.ics.uci.edu/pub</ulink>, 
+<ulink url="ftp://belmont-shores.ics.uci.edu/pub">ftp://belmont-shores.ics.uci.edu/pub</ulink>, or <ulink url="http://www.perl.com/CPAN">Perl CPAN</ulink>.
+</para>
+</sect2>
+
+<sect2 id="bugreport">
+<title>Bug Report</title>
+<para>Please submit any related bugs, issues, suggestions, or comments to <ulink url="http://belmont-shores.ics.uci.edu/bugzilla">http://belmont-shores.ics.uci.edu/bugzilla</ulink>.</para>
+</sect2>
+</sect1>
+
+</article>
+

Added: branches/upstream/libxml-node-perl/current/foo.xml
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-node-perl/current/foo.xml?rev=10515&op=file
==============================================================================
--- branches/upstream/libxml-node-perl/current/foo.xml (added)
+++ branches/upstream/libxml-node-perl/current/foo.xml Sat Dec  1 12:33:50 2007
@@ -1,0 +1,1 @@
+<foo type="SomeThing">x<bar><p>a</p></bar>y</foo>

Added: branches/upstream/libxml-node-perl/current/orders.xml
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-node-perl/current/orders.xml?rev=10515&op=file
==============================================================================
--- branches/upstream/libxml-node-perl/current/orders.xml (added)
+++ branches/upstream/libxml-node-perl/current/orders.xml Sat Dec  1 12:33:50 2007
@@ -1,0 +1,20 @@
+<Orders>
+  These are the orders:
+  <Order ID="0008" Date="11/14/1999">
+    <Item>A Book</Item>
+    <Quantity>1</Quantity>
+    <TagsThatIDontCare>Something</TagsThatIDontCare>
+   </Order>
+   <TagsThatIDontCare>Blah Blah</TagsThatIDontCare>
+   <Order>
+    <Item>A Pencil</Item>
+    <Quantity>2</Quantity>
+    <TagsThatIDontCare>Something</TagsThatIDontCare>
+   </Order>
+   <Order ID="0018" Date="11/15/1999">
+    <Item>A Pen</Item>
+    <Quantity>4</Quantity>
+    <TagsThatIDontCare>Something</TagsThatIDontCare>
+   </Order>
+   End of all orders.
+</Orders>

Added: branches/upstream/libxml-node-perl/current/parse-foo.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-node-perl/current/parse-foo.pl?rev=10515&op=file
==============================================================================
--- branches/upstream/libxml-node-perl/current/parse-foo.pl (added)
+++ branches/upstream/libxml-node-perl/current/parse-foo.pl Sat Dec  1 12:33:50 2007
@@ -1,0 +1,22 @@
+#!/usr/bin/perl -w
+use XML::Node;
+
+$xml_node = XML::Node->new();
+
+$xml_node->register( "foo", 'char' => \$variable );
+$xml_node->register( "foo>bar", "start" => sub { print "foo-bar[start](relative)\n" } );
+$xml_node->register( "foo>bar", "end" => sub { print "foo-bar[end](relative)\n" } );
+$xml_node->register( ">foo>bar", "end" => sub { print "foo-bar[end](absolute)\n" } );
+$xml_node->register( ">foo:type", "attr" => sub { print "foo-type[attr](absolute)\n" } );
+$xml_node->register( "foo:type", "attr" => sub { print "foo-type[attr](relative)\n" } );
+
+my $file = "foo.xml";
+
+print "Processing file [$file]...\n";
+
+open(FOO, $file);
+$xml_node->parse(*FOO);
+close(FOO);
+
+print "<foo> has content: [$variable]\n";
+

Added: branches/upstream/libxml-node-perl/current/parse-orders.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-node-perl/current/parse-orders.pl?rev=10515&op=file
==============================================================================
--- branches/upstream/libxml-node-perl/current/parse-orders.pl (added)
+++ branches/upstream/libxml-node-perl/current/parse-orders.pl Sat Dec  1 12:33:50 2007
@@ -1,0 +1,42 @@
+#!/usr/bin/perl -w
+use XML::Node;
+
+my $item = "";
+my $quantity = "";
+my $id = "";
+my $date = "";
+my $orders = "";
+
+$p = XML::Node->new();
+
+$p->register(">Orders","start" => \&handle_orders_start);
+$p->register(">Orders","char" => \$orders);
+$p->register(">Orders>Order:ID","attr" => \$id);
+$p->register(">Orders>Order:Date","attr" => \$date);
+$p->register(">Orders>Order>Item","char" => \$item);
+$p->register(">Orders>Order>Quantity","char" => \$quantity);
+$p->register(">Orders>Order","end" => \&handle_order_end);
+$p->register(">Orders","end" => \&handle_orders_end);
+
+print "Processing file [orders.xml]...\n";
+$p->parsefile("orders.xml");
+
+sub handle_orders_start
+{
+    print "Start of all orders\n-----\n$orders\n----\n";
+}
+
+sub handle_order_end
+{
+    print "Found order [$id] [$date] -- Item: [$item] Quantity: [$quantity]\n";
+    $date = "";
+    $id="";
+    $item = "";
+    $quantity = "";
+}
+
+sub handle_orders_end
+{
+    print "End of all orders\n-----\n$orders\n----\n";
+}
+

Added: branches/upstream/libxml-node-perl/current/parse-testsuite.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-node-perl/current/parse-testsuite.pl?rev=10515&op=file
==============================================================================
--- branches/upstream/libxml-node-perl/current/parse-testsuite.pl (added)
+++ branches/upstream/libxml-node-perl/current/parse-testsuite.pl Sat Dec  1 12:33:50 2007
@@ -1,0 +1,49 @@
+#!/usr/bin/perl -w
+#
+
+use XML::Node;
+
+# The following sample script calculates how many test cases there are in 
+#   a test suite XML file.
+#
+# The XML file name can be passed as a parameter. Example:
+#   perl test.pl test.xml
+#
+
+my $suite_name = "";
+my $testcase_name = "";
+my $xml_filename = "test.xml";
+my $testcase_no = 0;
+my $arg1 = shift;
+
+if ($arg1) {
+    $xml_filename = $arg1;
+}
+
+$p = XML::Node->new();
+
+$p->register(">TestTalk>TestSuite>Name","char" => \$ suite_name);
+$p->register(">TestTalk>TestSuite>TestCase>Name","char" => \$testcase_name);
+$p->register(">TestTalk>TestSuite>TestCase","end" => \& handle_testcase_end);
+$p->register(">TestTalk>TestSuite","end" => \& handle_testsuite_end);
+
+print "\nProcessing file [$xml_filename]...\n\n";
+$p->parsefile($xml_filename);
+
+
+sub handle_testcase_end
+{
+    print "Found test case [$testcase_name]\n";
+    $testcase_name = "";
+    $testcase_no ++;
+}
+
+sub handle_testsuite_end
+{
+    print "\n--There are $testcase_no test cases in test suite [$suite_name]\n\n";
+    $testcase_name = "";
+}
+
+
+
+

Added: branches/upstream/libxml-node-perl/current/test.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-node-perl/current/test.pl?rev=10515&op=file
==============================================================================
--- branches/upstream/libxml-node-perl/current/test.pl (added)
+++ branches/upstream/libxml-node-perl/current/test.pl Sat Dec  1 12:33:50 2007
@@ -1,0 +1,38 @@
+#!/usr/bin/perl -w
+#
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+# (It may become useful if the test is moved to ./t subdirectory.)
+
+BEGIN { $| = 1; print "1..4\n"; }
+END {print "not ok 1\n" unless $loaded;}
+
+
+use XML::Node;
+
+$loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+print "invoking parse-testsuite.pl...\n";
+require "parse-testsuite.pl";
+print "ok 2\n";
+
+print "invoking parse-orders.pl...\n";
+require "parse-orders.pl";
+print "ok 3\n";
+
+print "invoking parse-foo.pl...\n";
+require "parse-foo.pl";
+print "ok 4\n";
+
+

Added: branches/upstream/libxml-node-perl/current/test.xml
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-node-perl/current/test.xml?rev=10515&op=file
==============================================================================
--- branches/upstream/libxml-node-perl/current/test.xml (added)
+++ branches/upstream/libxml-node-perl/current/test.xml Sat Dec  1 12:33:50 2007
@@ -1,0 +1,67 @@
+<TestTalk>

+  <TestSuite>

+<!--  This test suite has all the test case that work -->

+   <Name>ClientTestSuite1</Name>

+   <TestCase>

+      <Name>SimpleText</Name>

+      <Properties>SanityCheck</Properties>

+      <!--Properies can used to select test cases or to analyze test coverage.-->

+      <Action-GetPage>

+         <Url>http://localhost:8082</Url>

+         <Oracle-Text>

+            <Text>It Worked!</Text>

+         </Oracle-Text>

+	 <!-- This oracle is closely related to the action, meaning there is data dependency here, so it's put here as an element. -->

+      </Action-GetPage>

+   </TestCase>

+   <TestCase>

+      <Name>ServerLog</Name>

+      <Action-GetPage>

+         <Url>http://localhost</Url>

+      </Action-GetPage>

+         <Oracle-MatchServerLog>

+            <ServerLogName>access_log</ServerLogName>

+            <Match>127.0.0.1 - - \[22/Oct/1999:.*GET / HTTP/1\.0</Match>

+	    <!-- change this to your test time -->

+         </Oracle-MatchServerLog>

+	 <!-- This oracle is independent. So it's placed here as a top-level oracle. -->

+   </TestCase>

+   <TestCase>

+      <Name>OracleCombo</Name>

+      <Properties>SanityCheck</Properties>

+      <!--Properies can used to select test cases or to analyze test coverage.-->

+      <Action-GetPage>

+         <Url>http://localhost:8082</Url>

+         <Oracle-Combo>

+           <Code>200</Code>

+           <Title>1:Test Page for Apache Installation on Web Site</Title>

+           <Lines>51</Lines>

+           <Bytes>1626</Bytes>

+         </Oracle-Combo>   

+      </Action-GetPage>

+   </TestCase>

+   <TestCase>

+      <Name>ChangeDocumentRoot</Name>

+      <Properties>RocumentRoot</Properties>

+      <!--The test case tests for the DocumentRoot directive in the Apache configuration files.-->

+      <Action-RestartServer>

+         <ServerTestCaseName>DocumentRoot22</ServerTestCaseName>

+      </Action-RestartServer>

+      <Action-GetPage>

+         <Url>http://localhost:8082</Url>

+         <Oracle-Text>

+            <Text>2:It Worked!</Text>

+         </Oracle-Text>

+      </Action-GetPage>

+      <Action-RestartServer>

+         <ServerTestCaseName>DocumentRoot21</ServerTestCaseName>

+      </Action-RestartServer>

+      <Action-GetPage>

+         <Url>http://localhost:8082</Url>

+         <Oracle-Text>

+            <Text>1:It Worked!</Text>

+         </Oracle-Text>

+      </Action-GetPage>

+   </TestCase>

+</TestSuite>

+</TestTalk>




More information about the Pkg-perl-cvs-commits mailing list