Mercurial > pub > Impl
changeset 16:75d55f4ee263
Окончательная концепция описания схем и построения DOM документов
author | Sergey |
---|---|
date | Tue, 08 Sep 2009 17:29:07 +0400 |
parents | 16795016e70b |
children | 7f88e01b58f8 |
files | Lib/IMPL/DOM/Navigator/Builder.pm Lib/IMPL/DOM/Node.pm Lib/IMPL/DOM/Schema.pm |
diffstat | 3 files changed, 106 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Navigator/Builder.pm Mon Sep 07 17:30:55 2009 +0400 +++ b/Lib/IMPL/DOM/Navigator/Builder.pm Tue Sep 08 17:29:07 2009 +0400 @@ -92,7 +92,7 @@ =back - C<nodeName>. + C<nodeName>. .. C<< <ComplexNode nodeName="Box" type="Container"> >> C<< Container->new(nodeName => 'Box') >>.
--- a/Lib/IMPL/DOM/Node.pm Mon Sep 07 17:30:55 2009 +0400 +++ b/Lib/IMPL/DOM/Node.pm Tue Sep 08 17:29:07 2009 +0400 @@ -41,7 +41,7 @@ } sub appendNode { - my ($this,$node,$pos) = @_; + my ($this,$node) = @_; die new IMPL::InvalidOperationException("You can't insert the node to itselft") if $this == $node; @@ -54,6 +54,21 @@ return $node; } +sub appendRange { + my ($this,@range) = @_; + + die new IMPL::InvalidOperationException("You can't insert the node to itselft") if grep $_ == $this, @range; + + foreach my $node (@range) { + $node->{$parentNode}->removeNode($node) if ($node->{$parentNode}); + $node->_setParent( $this ); + } + + $this->childNodes->Append(@range); + + return $this; +} + sub _getChildNodes { my ($this) = @_;
--- a/Lib/IMPL/DOM/Schema.pm Mon Sep 07 17:30:55 2009 +0400 +++ b/Lib/IMPL/DOM/Schema.pm Tue Sep 08 17:29:07 2009 +0400 @@ -12,4 +12,93 @@ private _direct property _TypesMap => prop_all; } +sub ResoveType { + $_[0]->{$_TypesMap}->{$_[1]}; +} + +sub MetaSchema { + my $schema = new IMPL::DOM::Schema(nodeName => 'schema'); + + $schema->appendRange( + IMPL::DOM::Schema::ComplexNode->new(nodeName => 'schema')->appendRange( + IMPL::DOM::Schema::NodeSet->new()->appendRange( + IMPL::DOM::Schema::Node->new(nodeName => 'ComplexNode', type => 'ComplexNode', minOccur => 0, maxOccur=>'unbounded'), + IMPL::DOM::Schema::Node->new(nodeName => 'ComplexType', type => 'ComplexType', minOccur => 0, maxOccur=>'unbounded'), + IMPL::DOM::Schema::Node->new(nodeName => 'SimpleNode', type => 'SimpleNode', minOccur => 0, maxOccur=>'unbounded'), + IMPL::DOM::Schema::Node->new(nodeName => 'SimpleType', type => 'SimpleType', minOccur => 0, maxOccur=>'unbounded'), + IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur=>'unbounded'), + IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Include', minOccur => 0, maxOccur=>'unbounded') + ) + ), + IMPL::DOM::Schema::ComplexType->new(type => 'NodeSet', native => 'IMPL::DOM::Schema::NodeSet')->appendRange( + IMPL::DOM::Schema::NodeSet->new()->appendRange( + IMPL::DOM::Schema::Node->new(nodeName => 'ComplexNode', type => 'ComplexNode', minOccur => 0, maxOccur=>'unbounded'), + IMPL::DOM::Schema::Node->new(nodeName => 'SimpleNode', type => 'SimpleNode', minOccur => 0, maxOccur=>'unbounded'), + IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur=>'unbounded'), + ) + ) + ) +} + 1; + +__END__ + +=pod + +=head1 META SCHEMA + + , + +<schema> + <ComplexNode nodeName="schema"> + <NodeSet> + <Node minOcuur="0" maxOccur="unbounded" nodeName="ComplexNode" type="ComplexNode"/> + <Node minOcuur="0" maxOccur="unbounded" nodeName="SimpleNode" type="SimpleNode"/> + <Node minOcuur="0" maxOccur="unbounded" nodeName="ComplexType" type="ComplexType"/> + <Node minOcuur="0" maxOccur="unbounded" nodeName="SimpleType" type="SimpleType"/> + <SimpleNode minOcuur="0" maxOccur="unbounded" nodeName="Node"/> + <SimpleNode minOcuur="0" maxOccur="unbounded" nodeName="Include"/> + </NodeSet> + </ComplexNode> + + <ComplexType type="NodeContainer"> + <NodeSet> + <Node minOcuur="0" maxOccur="unbounded" nodeName="ComplexNode" type="ComplexNode"/> + <Node minOcuur="0" maxOccur="unbounded" nodeName="SimpleNode" type="SimpleNode"/> + <SimpleNode minOcuur="0" maxOccur="unbounded" nodeName="Node"/> + </NodeSet> + </ComplexType> + + + <ComplexType type="ComplexType"> + <NodeList> + <Node nodeName="NodeSet" type="NodeContainer" minOcuur=0/> + <Node nodeName="NodeList" type="NodeContainer" minOccur=0/> + <AnyNode minOccur="0" maxOccur="unbounded"/> + </NodeList> + </ComplexType> + + <ComplexType type="ComplexNode"> + <NodeList> + <Node nodeName="NodeSet" type="NodeContainer" minOcuur=0/> + <Node nodeName="NodeList" type="NodeContainer" minOccur=0/> + <AnyNode minOccur="0" maxOccur="unbounded"/> + </NodeList> + </ComplexType> + + <ComplexType type="SimpleNode"> + <NodeSet> + <AnyNode minOccur=0 maxOccur="unbounded"/> + </NodeSet> + </ComplexType> + + <ComplexType type="SimpleType"> + <NodeSet> + <AnyNode minOccur=0 maxOccur="unbounded"/> + </NodeSet> + </ComplexType> + +</schema> + +=cut