Skip to content

Commit

Permalink
Migrated to XML::Rabbit sugar functions + bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
robinsmidsrod committed Oct 21, 2011
1 parent 173425a commit d927809
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 158 deletions.
4 changes: 3 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Revision history for W3C-XMLSchema

{{$NEXT}}
- Migrated to XML::Rabbit sugar functions

0.0.2 2010-07-04 14:18:45 Europe/Oslo
- Bumped required XML::Rabbit version

0.0.1 2010-06-13 13:34:21 Europe/Oslo
Initial version.
- Initial version
6 changes: 1 addition & 5 deletions README.mkdn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ W3C::XMLSchema - Parser for W3C XML Schema Definition (XSD)

# VERSION

version 0.0.2
version 0.0.3

# SYNOPSIS

Expand Down Expand Up @@ -32,10 +32,6 @@ from an XML Schema definition (aka XSD), as defined by the W3C.

# ATTRIBUTES

## namespace_map

Namespace map for XMLSchema definition.

## target_namespace

The namespace the schema definition targets.
Expand Down
2 changes: 1 addition & 1 deletion dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ license = Perl_5
copyright_holder = Robin Smidsrød

;Semantic versioning, see http://semver.org/
version = 0.0.2
version = 0.0.3

[NextRelease]
[@Git]
Expand Down
50 changes: 10 additions & 40 deletions lib/W3C/XMLSchema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,89 +2,59 @@ use strict;
use warnings;

package W3C::XMLSchema;
use Moose;
with 'XML::Rabbit::RootNode';
use XML::Rabbit::Root 0.1.0;

# ABSTRACT: Parser for W3C XML Schema Definition (XSD)

use 5.008;

=attr namespace_map
Namespace map for XMLSchema definition.
=cut

has '+namespace_map' => (
default => sub { {
'xsd' => 'http://www.w3.org/2001/XMLSchema',
} }
);
add_xpath_namespace 'xsd' => 'http://www.w3.org/2001/XMLSchema';

=attr target_namespace
The namespace the schema definition targets.
=cut

has 'target_namespace' => (
traits => [qw/XPathValue/],
xpath_query => './@targetNamespace',
);
has_xpath_value 'target_namespace' => './@targetNamespace';

=attr attribute_groups
A list of all the attribute groups defined. Instances of L<W3C::XMLSchema::AttributeGroup>.
=cut

has 'attribute_groups' => (
isa => 'ArrayRef[W3C::XMLSchema::AttributeGroup]',
traits => [qw/XPathObjectList/],
xpath_query => './xsd:attributeGroup',
);
has_xpath_object_list 'attribute_groups' => './xsd:attributeGroup' => 'W3C::XMLSchema::AttributeGroup';

=attr groups
A list of all the groups defined. Instances of L<W3C::XMLSchema::Group>.
=cut

has 'groups' => (
isa => 'ArrayRef[W3C::XMLSchema::Group]',
traits => [qw/XPathObjectList/],
xpath_query => './xsd:group',
);
has_xpath_object_list 'groups' => './xsd:group' => 'W3C::XMLSchema::Group';

=attr complex_types
A list of all the complex types defined. Instances of L<W3C::XMLSchema::ComplexType>.
=cut

has 'complex_types' => (
isa => 'ArrayRef[W3C::XMLSchema::ComplexType]',
traits => [qw/XPathObjectList/],
xpath_query => './xsd:complexType',
);
has_xpath_object_list 'complex_types' => './xsd:complexType' => 'W3C::XMLSchema::ComplexType';

=attr elements
A list of all the elements defined. Instances of L<W3C::XMLSchema::Element>.
=cut

has 'elements' => (
isa => 'ArrayRef[W3C::XMLSchema::Element]',
traits => [qw/XPathObjectList/],
xpath_query => './xsd:element',
);

no Moose;
__PACKAGE__->meta->make_immutable();
has_xpath_object_list 'elements' => './xsd:element' => 'W3C::XMLSchema::Element';

finalize_class();
1;

__END__
=head1 SYNOPSIS
use W3C::XMLSchema;
Expand Down
24 changes: 7 additions & 17 deletions lib/W3C/XMLSchema/Attribute.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use strict;
use warnings;

package W3C::XMLSchema::Attribute;
use Moose;
with 'XML::Rabbit::Node';
use XML::Rabbit;

# ABSTRACT: XMLSchema Attribute Definition

Expand All @@ -13,38 +12,29 @@ Name given to attribute.
=cut

has 'name' => (
traits => [qw/XPathValue/],
xpath_query => './@name',
);
has_xpath_value 'name' => './@name';

=attr type
Type given of attribute.
=cut

has 'type' => (
traits => [qw/XPathValue/],
xpath_query => './@type',
);
has_xpath_value 'type' => './@type';

=attr use
If the attribute is required or not. A string with the value 'required' or 'optional';
=cut

has 'use' => (
traits => [qw/XPathValue/],
xpath_query => './@use',
);

no Moose;
__PACKAGE__->meta->make_immutable();
has_xpath_value 'use' => './@use';

finalize_class();
1;

__END__
=head1 DESCRIPTION
Attribute, as defined by XMLSchema definition.
Expand Down
31 changes: 8 additions & 23 deletions lib/W3C/XMLSchema/AttributeGroup.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use strict;
use warnings;

package W3C::XMLSchema::AttributeGroup;
use Moose;
with 'XML::Rabbit::Node';
use XML::Rabbit;

# ABSTRACT: XMLSchema Attribute Group Definition

Expand All @@ -13,51 +12,37 @@ Name given to attribute group.
=cut

has 'name' => (
traits => [qw/XPathValue/],
xpath_query => './@name',
);
has_xpath_value 'name' => './@name';

=attr ref
Name of other AttributeGroup this attribute group references.
=cut

has 'ref' => (
traits => [qw/XPathValue/],
xpath_query => './@ref',
);
has_xpath_value 'ref' => './@ref';

=attr attribute_groups
Child AttributeGroup of this AttributeGroup. Mostly used for referencing other AttributeGroups.
=cut

has 'attribute_groups' => (
isa => 'ArrayRef[W3C::XMLSchema::AttributeGroup]',
traits => [qw/XPathObjectList/],
xpath_query => './xsd:attributeGroup',
);
has_xpath_object_list 'attribute_groups' => './xsd:attributeGroup' => 'W3C::XMLSchema::AttributeGroup';

=attr attributes
List of attributes associated with this attribute group. Instance type L<W3C::XMLSchema::Attribute>.
=cut

has 'attributes' => (
isa => 'ArrayRef[W3C::XMLSchema::Attribute]',
traits => [qw/XPathObjectList/],
xpath_query => './xsd:attribute',
);

no Moose;
__PACKAGE__->meta->make_immutable();
has_xpath_object_list 'attributes' => './xsd:attribute' => 'W3C::XMLSchema::Attribute';

finalize_class();
1;

__END__
=head1 DESCRIPTION
AttributeGroups, as defined by XMLSchema definition.
Expand Down
27 changes: 9 additions & 18 deletions lib/W3C/XMLSchema/ComplexType.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use strict;
use warnings;

package W3C::XMLSchema::ComplexType;
use Moose;
with 'XML::Rabbit::Node';
use XML::Rabbit;

# ABSTRACT: XMLSchema ComplexType Definition

Expand All @@ -13,21 +12,15 @@ Name given to complex type.
=cut

has 'name' => (
traits => ['XPathValue'],
xpath_query => './@name',
);
has_xpath_value 'name' => './@name';

=attr mixed
True if complex type contains mixed content.
=cut

has 'mixed' => (
traits => ['XPathValue'],
xpath_query => './@mixed',
);
has_xpath_value 'mixed' => './@mixed';

=attr items
Expand All @@ -37,20 +30,18 @@ composed of simple types, either elements or attributes.
=cut

has 'items' => (
traits => ['XPathObjectList'],
xpath_query => './*',
isa_map => {
has_xpath_object_list 'items' => './*',
{
'xsd:group' => 'W3C::XMLSchema::Group',
'xsd:attributeGroup' => 'W3C::XMLSchema::AttributeGroup',
},
);

no Moose;
__PACKAGE__->meta->make_immutable();
;

finalize_class();
1;

__END__
=head1 DESCRIPTION
ComplexTypes, as defined by XMLSchema definition.
Expand Down
Loading

0 comments on commit d927809

Please sign in to comment.