| XML-Validator-Schema documentation | Contained in the XML-Validator-Schema distribution. |
XML::Validator::Schema::ElementRefNode - an element reference node
This is an internal module used by XML::Validator::Schema to represent an element reference node.
| XML-Validator-Schema documentation | Contained in the XML-Validator-Schema distribution. |
package XML::Validator::Schema::ElementRefNode; use strict; use warnings; use base 'XML::Validator::Schema::ElementNode'; use XML::Validator::Schema::Util qw(_err _attr); use Carp qw(croak);
sub parse { my ($pkg, $data) = @_; my $self = $pkg->new(); my $ref = _attr($data, 'ref'); croak("Why did you create an ElementRefNode if you didn't have a ref?") unless $ref; $self->{unresolved_ref} = 1; $self->name($ref); my $name = _attr($data, 'name'); _err("Found <element> with illegal combination of 'ref' and 'name' ". "attributes.") if $name; my $type_name = _attr($data, 'type'); _err("Found <element> with illegal combination of 'ref' and 'type' ". "attributes.") if $type_name; my $min = _attr($data, 'minOccurs'); $min = 1 unless defined $min; _err("Invalid value for minOccurs '$min' found in <element>.") unless $min =~ /^\d+$/; $self->{min} = $min; my $max = _attr($data, 'maxOccurs'); $max = 1 unless defined $max; _err("Invalid value for maxOccurs '$max' found in <element>.") unless $max =~ /^\d+$/ or $max eq 'unbounded'; $self->{max} = $max; return $self; } 1;