The Common Data Format (CDF), enforces a standard XML data schema with a root element called data, nested elements called record and record attributes such as jsxid, jsxtext and jsximg. This schema applies to the classes that implement the jsx3.xml.CDF interface: Select, Tree, Menu, Table and Matrix (and previously List and Grid). Standard CDF schema example<data jsxid="jsxroot"> <record jsxid="1" jsxtext="One" jsximg="one.gif"/> <record jsxid="2" jsxtext="Two" jsximg="two.gif"/> ... </data> The flexible CDF schema feature allows these same classes to consume datasources that do not strictly follow CDF. This feature is particularly useful for consuming pre-existing XML datasources that were created without knowledge of CDF. With the flexible CDF schema feature,
How Flexible CDF Schema WorksEach CDF control has a schema property of type jsx3.xml.CDFSchema. The value of this property defines how the control views its CDF datasource. If the schema property is not set then the control uses the default CDF schema. Each CDF control first queries its schema for the name of the text attribute and then queries its datasource for that attribute of a record. For example, the implementation of jsx3.gui.Tree includes expressions such as this.getRecordNode(id).getAttribute(this.getSchema().getProp("text")) This additional level of indirection (this.getSchema().getProp("text") instead of "jsxtext") allows the CDFSchema object to control how each CDF control views its datasource. The default CDFSchema object returns "jsxtext" from a call to getProp("text"). However, you can modify the schema so that it returns "label" instead. This change would allow you to have a CDF datasource such as <data jsxid="jsxroot"> <record jsxid="1" label="One"/> ... </data> Controlling Flexible CDF Schema in General Interface BuilderYou can control flexible CDF schema from within General Interface Builder. To do so,
The Properties Editor contains an editable property for each attribute in the default CDF schema. In general, the default value of property abc is jsxabc. CDFSchema also has a property called record. This property allows you to change the element name of the records in the datasource. You can choose another name, such as item or you can use set it to * to indicate than any XML element should be interpreted as a data record.
For the CDF schema shown in the screenshot, the datasource is <items id="jsxroot"> <item id="1" label="One"/> <thing id="2" label="Two"/> <object id="3" label="Three"/> ... </items> Using the same datasource for two different controls is simply a matter of defining a unique CDF schema for each control. Click to download a sample project that uses the flexible CDF schema feature: GI-702.zip. |
Contents
|

