Mercurial > pub > Impl
changeset 219:c477f24f1980
sync
author | sergey |
---|---|
date | Tue, 21 Aug 2012 17:13:47 +0400 |
parents | 358f867712b4 |
children | 5c82c15b25b1 |
files | Lib/IMPL/Serialization.pm _test/Resources/resources.xsd _test/Resources/sample.xml _test/temp.pl |
diffstat | 4 files changed, 86 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/Lib/IMPL/Serialization.pm Mon Aug 20 17:24:48 2012 +0400 +++ b/Lib/IMPL/Serialization.pm Tue Aug 21 17:13:47 2012 +0400 @@ -182,7 +182,7 @@ die new Exception("A reference to a not existing object found") if not $refObj; my $rhCurrentObj = $this->{$CurrentObject}; - die new Exception("Found a reference to an object as a root of an object's graph") if not $rhCurrentObj; + die new Exception("The root object can't be a reference") if not $rhCurrentObj; if ($rhCurrentObj->{'Data'}) { die new Exception("Invalid serializaed data","Plain deserialization data for an object already exist") if not ref $rhCurrentObj->{'Data'};
--- a/_test/Resources/resources.xsd Mon Aug 20 17:24:48 2012 +0400 +++ b/_test/Resources/resources.xsd Tue Aug 21 17:13:47 2012 +0400 @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> -<schema targetNamespace="uri:impl-web-application/resources" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="uri:impl-web-application/resources"> +<schema targetNamespace="http://implab.org/schemas/resources" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://implab.org/schemas/resources"> <element name="resources"> <complexType> <sequence> <element name="root" type="tns:restResource"></element> - <element name="typeMap"> + <element name="typeMap" minOccurs="0"> <complexType> <sequence> - <element name="item"> + <element name="item" maxOccurs="unbounded"> <complexType> <complexContent> <extension @@ -25,6 +25,11 @@ </complexType> </element> + <!-- abstract types --> + <complexType name="abstractBinding" abstract="true"/> + <complexType name="abstractTransformation" abstract="true" /> + <complexType name="abstractResult" abstract="true" /> + <complexType name="restResource"> <sequence> <element name="get" type="tns:restOperation" minOccurs="0"> @@ -41,9 +46,69 @@ <complexType name="restOperation"> <sequence> - <element name="invoke" type="string"></element> + <element ref="tns:abstractBinding"/> <element name="parameters" type="string"></element> - <element name="result" type="string"></element> + <element ref="tns:abstractResult"/> </sequence> </complexType> + + <complexType name="methodBinding" > + <complexContent> + <extension base="tns:abstractBinding"> + <attribute name="target" type="string" /> + <attribute name="invoke" type="string" use="required" /> + </extension> + </complexContent> + </complexType> + + <complexType name="transformation"> + <attribute name="class" type="string" /> + </complexType> + + <complexType name="resourceLocator"> + <sequence> + <element ref="tns:abstractBinding" /> + <element name="template" type="string" /> + </sequence> + </complexType> + + + + + <!-- substitutions --> + + <!-- abstract --> + <element name="abstractBinding" type="tns:abstractBinding" abstract="true"/> + <element name="abstractTransfomation" type="tns:abstractTransformation" /> + <element name="abstractResult" type="tns:abstractResult" abstract="true" /> + + <!-- specific --> + + <!-- bindings --> + <element name="bind" type="tns:methodBinding" substitutionGroup="tns:abstractBinding"/> + + <!-- transformation --> + + <!-- result handlers --> + <simpleType name="redirectCodes"> + <restriction base="string"> + <enumeration value="moved-permanently"/> + <enumeration value="temporary-redirect"/> + <enumeration value="see-other"/> + </restriction> + </simpleType> + + <complexType name="redirectResult"> + <complexContent> + <extension base="tns:abstractResult"> + <sequence> + <element name="locator" type="tns:resourceLocator" /> + <element name="status" type="tns:redirectCodes" minOccurs="0"/> + </sequence> + </extension> + </complexContent> + </complexType> + + <element name="redirect" type="tns:redirectResult" substitutionGroup="tns:abstractResult" /> + </schema> \ No newline at end of file
--- a/_test/Resources/sample.xml Mon Aug 20 17:24:48 2012 +0400 +++ b/_test/Resources/sample.xml Tue Aug 21 17:13:47 2012 +0400 @@ -1,17 +1,19 @@ <?xml version="1.0" encoding="UTF-8"?> -<resources xmlns="uri:impl-web-application/resources" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:impl-web-application/resources resources.xsd "> +<resources xmlns="http://implab.org/schemas/resources" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://implab.org/schemas/resources resources.xsd "> <root> <get> - <invoke/> - <parameters> - <transform class=""/> - </parameters> - <result></result> + <bind invoke="."/> + <parameters></parameters> + <redirect> + <locator> + <bind invoke="id"/> + <template>$parent/$id</template> + </locator> + </redirect> </get> </root> <typeMap> - <item model="My::App::Model::User"> - <get></get> - </item> + <item></item> + <item></item> </typeMap> </resources> \ No newline at end of file
--- a/_test/temp.pl Mon Aug 20 17:24:48 2012 +0400 +++ b/_test/temp.pl Tue Aug 21 17:13:47 2012 +0400 @@ -2,20 +2,20 @@ use strict; use XML::Compile::Schema; -use XML::Compile::Util qw(pack_type); +use XML::Compile::Util qw(pack_type pack_id); use Data::Dumper; use Time::HiRes qw(gettimeofday tv_interval); -my $schema = XML::Compile::Schema->new('Resources/person.xsd'); +my $schema = XML::Compile::Schema->new('Resources/resources.xsd'); $schema->printIndex(); -my $type = pack_type 'http://implab.org/person/', 'personInfo'; +my $type = pack_type 'http://implab.org/schemas/resources', 'resources'; my $reader = $schema->compile(READER => $type); my $t = [gettimeofday]; -my $obj = $reader->('Resources/person_info.xml'); +my $obj = $reader->('Resources/sample.xml'); print "Parsing small Xml file: ",tv_interval($t,[gettimeofday]),"\n";