Rinchi-XMLSchema
view release on metacpan or search on metacpan
lib/Rinchi/XMLSchema.pm view on Meta::CPAN
package Rinchi::XMLSchema;
use 5.006;
use strict;
use strict;
use Carp;
use XML::Parser;
#use Class::ISA;
our @ISA = qw();
our @EXPORT = qw();
our @EXPORT_OK = qw();
our $VERSION = 0.02;
=head1 NAME
Rinchi::XMLSchema - Module for creating XML Schema objects from XSD files.
=head1 SYNOPSIS
use Rinchi::XMLSchema;
$document = Rinchi::XMLSchema->parse($file);
=head1 DESCRIPTION
This module parses XML Schema files and produces Perl objects representing
them. There is also the capability to compare objects to see if they are the
same (not necessarily equal). The intent of this module is to allow the
comparison of various schemas to find common constructs between them. A
module I intend to release later will allow the production of UML from
schema files.
Note: Imports and includes are not performed as at this time that would be
contrary to the purpose of the module.
=head2 EXPORT
None by default.
=cut
my %sax_handlers = (
'Init' => \&handle_init,
'Final' => \&handle_final,
'Start' => \&handle_start,
'End' => \&handle_end,
'Char' => \&handle_char,
'Proc' => \&handle_proc,
'Comment' => \&handle_comment,
'CdataStart' => \&handle_cdata_start,
'CdataEnd' => \&handle_cdata_end,
'Default' => \&handle_default,
'Unparsed' => \&handle_unparsed,
'Notation' => \&handle_notation,
'ExternEnt' => \&handle_extern_ent,
'ExternEntFin' => \&handle_extern_ent_fin,
'Entity' => \&handle_entity,
'Element' => \&handle_element,
'Attlist' => \&handle_attlist,
'Doctype' => \&handle_doctype,
'DoctypeFin' => \&handle_doctype_fin,
'XMLDecl' => \&handle_xml_decl,
);
my %sax_start_handlers = (
'all' => \&handle_start_all,
'annotation' => \&handle_start_annotation,
'any' => \&handle_start_any,
'anyAttribute' => \&handle_start_anyAttribute,
'appinfo' => \&handle_start_appinfo,
'attribute' => \&handle_start_attribute,
'attributeGroup' => \&handle_start_attributeGroup,
'choice' => \&handle_start_choice,
'complexContent' => \&handle_start_complexContent,
'complexType' => \&handle_start_complexType,
'documentation' => \&handle_start_documentation,
'element' => \&handle_start_element,
'enumeration' => \&handle_start_enumeration,
'extension' => \&handle_start_extension,
'field' => \&handle_start_field,
'fractionDigits' => \&handle_start_fractionDigits,
'group' => \&handle_start_group,
'import' => \&handle_start_import,
'include' => \&handle_start_include,
'key' => \&handle_start_key,
'keyref' => \&handle_start_keyref,
'length' => \&handle_start_length,
'list' => \&handle_start_list,
'maxExclusive' => \&handle_start_maxExclusive,
'maxInclusive' => \&handle_start_maxInclusive,
'maxLength' => \&handle_start_maxLength,
'minExclusive' => \&handle_start_minExclusive,
'minInclusive' => \&handle_start_minInclusive,
'minLength' => \&handle_start_minLength,
'notation' => \&handle_start_notation,
'pattern' => \&handle_start_pattern,
'redefine' => \&handle_start_redefine,
'restriction' => \&handle_start_restriction,
'schema' => \&handle_start_schema,
'selector' => \&handle_start_selector,
'sequence' => \&handle_start_sequence,
'simpleContent' => \&handle_start_simpleContent,
'simpleType' => \&handle_start_simpleType,
'totalDigits' => \&handle_start_totalDigits,
'union' => \&handle_start_union,
'unique' => \&handle_start_unique,
'whiteSpace' => \&handle_start_whiteSpace,
);
my %sax_end_handlers = (
'all' => \&handle_end_all,
lib/Rinchi/XMLSchema.pm view on Meta::CPAN
#=================================================================
# End (Expat, Tag)
sub handle_end() {
my ($expat, $tag) = @_;
my $prefix;
my $local;
if ($tag =~ /^([A-Za-z]+):([A-Za-z]+)$/) {
$prefix = $1;
$local = $2;
} else {
$local = $tag;
}
my $Element;
if (defined($prefix)) {
if(exists($namespace_prefixes{$prefix})
and defined($namespace_prefixes{$prefix}->[0])
and exists($namespaces{$namespace_prefixes{$prefix}->[-1]})
and exists($namespaces{$namespace_prefixes{$prefix}->[-1]}->{'End'})
and exists($namespaces{$namespace_prefixes{$prefix}->[-1]}->{'End'}{$local})
) {
$namespaces{$namespace_prefixes{$prefix}->[-1]}->{'End'}{$local}(@_,$elem_stack[-1]);
}
} elsif(@namespace_stack
and exists($namespace_stack[-1]->{'End'})
and exists($namespace_stack[-1]->{'End'}{$local})
) {
$namespace_stack[-1]->{'End'}{$local}(@_,$elem_stack[-1]);
}
$Document = pop @elem_stack;
}
#=================================================================
# Char (Expat, String)
sub handle_char() {
my ($expat, $string) = @_;
$elem_stack[-1]->{'_text'} .= $string unless (ref($elem_stack[-1]) =~ /^Rinchi::XMLSchema/);
}
#=================================================================
# Proc (Expat, Target, Data)
sub handle_proc() {
my ($expat, $target, $data) = @_;
}
#=================================================================
# Comment (Expat, Data)
sub handle_comment() {
my ($expat, $data) = @_;
}
#=================================================================
# CdataStart (Expat)
sub handle_cdata_start() {
my ($expat) = @_;
}
#=================================================================
# CdataEnd (Expat)
sub handle_cdata_end() {
my ($expat) = @_;
}
#=================================================================
# Default (Expat, String)
sub handle_default() {
my ($expat, $string) = @_;
}
#=================================================================
# Unparsed (Expat, Entity, Base, Sysid, Pubid, Notation)
sub handle_unparsed() {
my ($expat, $entity, $base, $sysid, $pubid, $notation) = @_;
}
#=================================================================
# Notation (Expat, Notation, Base, Sysid, Pubid)
sub handle_notation() {
my ($expat, $notation, $base, $sysid, $pubid) = @_;
}
#=================================================================
# ExternEnt (Expat, Base, Sysid, Pubid)
sub handle_extern_ent() {
my ($expat, $base, $sysid, $pubid) = @_;
}
#=================================================================
# ExternEntFin (Expat)
sub handle_extern_ent_fin() {
my ($expat) = @_;
}
#=================================================================
# Entity (Expat, Name, Val, Sysid, Pubid, Ndata, IsParam)
sub handle_entity() {
my ($expat, $name, $val, $sysid, $pubid, $ndata, $isParam) = @_;
}
#=================================================================
# Element (Expat, Name, Model)
sub handle_element() {
my ($expat, $name, $model) = @_;
}
#=================================================================
# Attlist (Expat, Elname, Attname, Type, Default, Fixed)
sub handle_attlist() {
my ($expat, $elname, $attname, $type, $default, $fixed) = @_;
}
#=================================================================
( run in 1.790 second using v1.01-cache-2.11-cpan-995e09ba956 )