Editing XML

    The model can be saved in XML. If you want to edit the model's XML manually, you can try the following methods.

1.Model file suffix name

    The suffix name of the manually written model XML file is .dml.xml, and the file of .dml.xml is recognized as the model.

2.Generate XSD

     XWorker provides a tool to generate Schema files for descriptors (classes) of models, either through Java code or through actions.

2.1.Java Code

import org.xmeta.Thing;
import xworker.doc.schema.ThingDocument;

Thing descriptor = world.getThing("xxx");
ThingDocument tdoc = new ThingDocument(descriptor);
tdoc.write("./test.xsd");

    The ThingDocument class can be found in the Lib directory or Maven of XWorker under the xwoker_core project of XWorker.

2.2.Generating XSD with actions

    The corresponding action model is GenerateThingSchema, grouped into _actions. thing, which can be searched by name when adding actions.

2.3.XSD Error

    The generated XSD file displays an error when editing XML, which can be ignored without affecting the editing of XML.

3.Examples of editing XML

    Screenshot.

    Code example.

<?xml version="1.0" encoding="utf-8"?>

<Shell  xmlns="http://www.xworker.org/schema" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://www.xworker.org/schema http://www.xworker.org/schema/swt.xsd"
     name="shell" descriptors="xworker.swt.widgets.Shell" text="Text" RESIZE="true" width="640"
      height="480" label="Text">
    <FillLayout name="shellFillLayout"></FillLayout>
    <Group name="group" text="Text" label="Text">
        <RowLayout name="groupRowLayout" type="SWT.VERTICAL"></RowLayout>
        <Label name="text" shadow="SHADOW_OUT" text="Text"></Label>
        <Text name="text" _xmeta_id_="text1" SEARCH="true" BORDER="true">
            <text><![CDATA[The quick brown fox jumps over the lazy dog.
One Two Three]]></text>
        </Text>
        <Label name="password" shadow="SHADOW_OUT" text="Password"></Label>
        <Text name="password" _xmeta_id_="password1" PASSWORD="true" BORDER="true">
            <text><![CDATA[The quick brown fox jumps over the lazy dog.
One Two Three]]></text>
        </Text>
        <Label name="multi" shadow="SHADOW_OUT" text="MutilLine"></Label>
        <Text name="multiLine" style="MULTI" H_SCROLL="true" V_SCROLL="true" BORDER="true">
            <text><![CDATA[The quick brown fox jumps over the lazy dog.
One Two Three]]></text>
            <RowData name="rowData" width="400" height="100"></RowData>
        </Text>
    </Group>
</Shell>

 

Copyright ©  2007-2019 XWorker.org  版权所有  沪ICP备08000575号