annotate Lib/IMPL/DOM/Navigator/SchemaNavigator.pm @ 20:267460284fb3

DOM Schema
author Sergey
date Tue, 22 Sep 2009 17:17:38 +0400
parents 818c74b038ae
children 7f00786f8210
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
1 package IMPL::DOM::Navigator::SchemaNavigator;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
2 use strict;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
3 use warnings;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
4
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
5 use base qw(IMPL::DOM::Navigator);
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
6 use IMPL::Class::Property;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
7 use IMPL::Class::Property::Direct;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
8
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
9 __PACKAGE__->PassThroughArgs;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
10
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
11 BEGIN {
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
12 public _direct property Schema => prop_get;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
13 }
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
14
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
15 sub CTOR {
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
16 my ($this,$schema) = @_;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
17
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
18 $this->{$Schema} = $schema;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
19
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
20 die new IMPL::InvalidArgumentException("A schema object is required") unless $schema->isa('IMPL::DOM::Schema');
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
21 }
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
22
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
23 sub Navigate {
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
24 my ($this,$query) = @_;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
25
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
26 if (my ($newNode) = $this->Current->selectNodes($query)) {
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
27 if (ref $newNode eq 'IMPL::DOM::Schema::Node') {
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
28 $newNode = $this->{$Schema}->ResolveType($newNode->type) || $newNode;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
29 }
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
30 return $this->_NavigateNode($newNode);
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
31 } else {
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
32 return undef;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
33 }
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
34 }
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
35
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
36 1;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
37 __END__
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
38
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
39 =pod
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
40
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
41 =head1 DESCRIPTION
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
42
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
43 Навигатор для схемы, отличается от стандартного тем, что переходит по ссылкам вида <Node nodeName="SomeName" type="ReferencedType"/>.
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
44 При этом имя узла в который перешли будет отличаться от указанного в поисковом критерии.
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
45
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
46 =cut