home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / libxml-perl / examples / schema.pl < prev    next >
Encoding:
Text File  |  1999-08-10  |  1.4 KB  |  37 lines

  1. # This template file is in the Public Domain.
  2. # You may do anything you want with this file.
  3. #
  4. # $Id: schema.pl,v 1.1 1999/08/10 21:43:50 kmacleod Exp $
  5. #
  6.  
  7. # This is the example script in the XML::PatAct::ToObjects module doc,
  8. # it also uses XML::PatAct::MatchName and is an example of using PatAct
  9. # modules.
  10.  
  11. use XML::Parser::PerlSAX;
  12. use XML::PatAct::MatchName;
  13. use XML::PatAct::ToObjects;
  14.  
  15. my $patterns =
  16.     [
  17.      'schema'      => [ qw{ -holder                                  } ],
  18.      'table'       => [ qw{ -make Schema::Table                      } ],
  19.      'name'        => [ qw{ -field Name -as-string                   } ],
  20.      'summary'     => [ qw{ -field Summary -as-string                } ],
  21.      'description' => [ qw{ -field Description -grove                } ],
  22.      'column'      => [ qw{ -make Schema::Column -push-field Columns } ],
  23.      'unique'      => [ qw{ -field Unique -value 1                   } ],
  24.      'non-null'    => [ qw{ -field NonNull -value 1                  } ],
  25.      'default'     => [ qw{ -field Default -as-string                } ],
  26.      ];
  27.  
  28. my $matcher = XML::PatAct::MatchName->new( Patterns => $patterns );
  29. my $handler = XML::PatAct::ToObjects->new( Patterns => $patterns,
  30.                        Matcher => $matcher);
  31.  
  32. my $parser = XML::Parser::PerlSAX->new( Handler => $handler );
  33. $schema = $parser->parse(Source => { SystemId => $ARGV[0] } );
  34.  
  35. require 'dumpvar.pl';
  36. dumpvar('main', 'schema');
  37.