Techniques to create complex models is to use inheritance, such as the examples below.
<?xml version="1.0" encoding="utf-8"?> <thing name="ThingCollection" descriptors="xworker.lang.MetaDescriptor3" description="<p>使用继承可以构建复杂的事物。</p>"> <thing name="Shell" extends="xworker.swt.widgets.Shell"></thing> <thing name="SimpleControl" extends="xworker.http.controls.SimpleControl"></thing> <thing name="Person" extends="xworker.example.thing.creatething.Person"></thing> </thing>
As in the above code, ThingCollection define the Shell, SimpleControl and Person child nodes, These child nodes inherit the SWT Shell model, WEB frameworks and Person model, So you can write them in the ThingCollection model.
ThingCollection is a complex model.
<?xml version="1.0" encoding="utf-8"?> <ThingCollection name="ThingCollectionInstance" descriptors="xworker.example.thing.creatething.ThingCollection" mammalAttribute="test" animalAttribute="test" creatureAttribute="test"> <description><![CDATA[<h3>继承在描述者上的作用</h3> <p> 在描述者上使用继承可以轻松定义复杂的事物,首先它可以像面向对象那种通过类 (描述者相当于类)的继承从而定义复杂的事物,从而可以让事物的属性和子事物更加丰富。</p>]]></description> <Shell name="shell" text="一个窗口" RESIZE="true" width="640" height="480"></Shell> <Person name="Tom" age="30"> <Child name="Smith"></Child> </Person> <SimpleControl name="helloWorldWeb"> <view> <otherHeads><![CDATA[<meta http-equiv="content-type" content="text/html; charset=utf-8"> <LINK REL ="stylesheet" TYPE="text/css" HREF="fckeditor/2_6beta1/editor/css/fck_editorarea.css" TITLE="Style"/> <script type="text/javascript" src="js/xworker/InnerBrowserUtil.js"></script>]]></otherHeads> <htmlCode htmlCode="<h3>HelloWorld</h3>"></htmlCode> </view> <result name="success" value="xworker.example.thing.creatething.ThingCollectionInstance/@helloWorldWeb/@view"></result> </SimpleControl> </ThingCollection>
Copyright © 2007-2019 XWorker.org 版权所有 沪ICP备08000575号