Added sorting to elddoc lists and updated site pages for better english.

This commit is contained in:
Willem Cazander 2012-12-21 03:01:48 +01:00
parent aa9c9743d7
commit 4a700f98a6
10 changed files with 225 additions and 78 deletions

View file

@ -23,11 +23,12 @@
Load Modules
The default language loader of x4o load all 'META-INF/<language>/<language>-modules.xml' in the classpath.
So every extension library has its own modules definition file.
The default language loader of x4o loads all 'META-INF/<language>/<language>-modules.xml' resources found in the classpath.
So every extension library has its own modules definition file.
All options are allowed in multiple forms and order.
For xsd file see x4o-core classpath 'META-INF/language/modules-1.0.xsd'.
The xsd file can be found in the x4o-core project classpath 'META-INF/language/modules-1.0.xsd'.
+--
<?xml version="1.0" encoding="UTF-8"?>
@ -49,4 +50,17 @@ Load Modules
<eld-resource>foobar-lang-2.0.eld</eld-resource>
</language>
</modules>
+--
+--
* eld-resource
The eld-resource tag loads the eld resource relative from the modules xml resource.
* module-loader
The module-loader lets you define module extensions and namespaces in code.
* sibling-loader
The sibling-loader lets you load other languages into the language used.

View file

@ -275,7 +275,79 @@ public class BorderConverter extends AbstractStringObjectConverter {
}
+--
* XML to parse
+--
<frame name="mainframe" size="800,600" title="SWIXML-X4O" plaf="com.sun.java.swing.plaf.windows.WindowsLookAndFeel" defaultCloseOperation="3">
<menubar name="menubar">
<menu name="filemenu" text="File">
<menuitem name="mi_new" text="New" icon="icons/new.gif" mnemonic="VK_N" accelerator="control N" Action="newAction"/>
<menuitem name="mi_open" text="Open" icon="icons/open.gif" mnemonic="VK_O" Accelerator="control O" ActionCommand="open"/>
<menuitem name="mi_save" text="Save" icon="icons/save.gif" mnemonic="VK_S" ActionCommand="save"/>
<menu name="propmenu" text="Properties" icon="icons/new.gif" >
<menuitem name="mi_prop_edit" text="Edit" icon="icons/new.gif"/>
<menuitem name="mi_prop_clear" text="Clear" icon="icons/new.gif"/>
</menu>
<separator/>
<menuitem name="mi_exit" text="Exit" icon="icons/exit.gif" mnemonic="VK_X" Accelerator="control X" ActionCommand="exit" Action="exitAction"/>
</menu>
<menu text="Help">
<menuitem name="mi_about" text="About" enabled="true" icon="icons/info.gif" Accelerator="alt A" Action="aboutAction" />
</menu>
</menubar>
<desktoppane>
<internalframe Title="Flow Layout (right aligned)" Bounds="10,10,150,150" Layout="FlowLayout(FlowLayout.RIGHT)" Visible="true" Resizable="true">
<button>1</button>
<button>2</button>
<button>3</button>
<button>4</button>
</internalframe>
<internalframe Title="Grid Layout" Bounds="200,10,170,170" Layout="GridLayout(4,3)" Visible="true" Resizable="true">
<button text="1"/><button text="2"/><button text="3"/>
<button text="4"/><button text="5"/><button text="6"/>
<button text="7"/><button text="8"/><button text="9"/>
<button text="*"/><button text="0"/><button text="#"/>
</internalframe>
<internalframe Title="Border Layout" Bounds="390,10,150,150" Layout="borderlayout" Visible="true" Resizable="true">
<button constraints="BorderLayout.NORTH" text="1"/>
<button constraints="BorderLayout.EAST" text="2"/>
<button constraints="BorderLayout.SOUTH" text="3"/>
<button constraints="BorderLayout.WEST" text="4"/>
</internalframe>
<internalframe Title="Tree Window" Bounds="10,170,350,360" Layout="borderlayout" Visible="true" Resizable="true">
<panel layout="borderlayout" constraints="BorderLayout.CENTER">
<splitpane oneTouchExpandable="true" dividerLocation="200">
<splitpane oneTouchExpandable="true" dividerLocation="140" orientation="VERTICAL">
<scrollPane background="blue" >
<tree name="tree"/>
</scrollPane>
<panel layout="borderlayout">
<panel constraints="BorderLayout.NORTH">
<button name="btn_copy" ToolTipText="JPanel" enabled="true" BorderPainted="false" FocusPainted="false" icon="icons/copy.gif" size="24,24"/>
<button name="btn_paste" ToolTipText="JButton" enabled="true" BorderPainted="false" FocusPainted="false" icon="icons/paste.gif" size="24,24"/>
<button name="btn_cut" ToolTipText="JLabel" enabled="true" icon="icons/cut.gif" BorderPainted="false" FocusPainted="false" size="24,24"/>
</panel>
<scrollPane constraints="BorderLayout.CENTER">
<table name="table"/>
</scrollPane>
</panel>
</splitpane>
<panel name="preview" border="LoweredBevelBorder">
<textarea name="ta" text="Tree Status Log....." background="red"/>
</panel>
</splitpane>
</panel>
<panel constraints="BorderLayout.SOUTH">
<label text="Status:"/>
<textfield text="OK"/>
</panel>
</internalframe>
</desktoppane>
</frame>
+--
* Source
This example is found in the x4o-core source package in the test path.
This example is found in the x4o-core source package in the test java and resouces path.

View file

@ -55,6 +55,12 @@ public class FooBarParserSupport implements X4OParserSupport {
FooBarParser parser = new FooBarParser();
return parser.loadElementLanguageSupport();
}
public TestBeanRoot getRoot() {
// Simple way to return single root object.
// note; element tree is cleared after parsing only root element is there.
return (TestBeanRoot)getDriver().getElementLanguage().getRootElement().getElementObject();
}
}
+--
@ -127,4 +133,24 @@ public class FooBarParserSupport implements X4OParserSupport {
+--
Now you can startup the parser to see it work.
* Create xml to parse
+--
<?xml version="1.0" encoding="UTF-8"?>
<r:root
xmlns:l="http://foobar.test.x4o.org/xml/ns/foobar-lang"
xmlns:r="http://foobar.test.x4o.org/xml/ns/foobar-root""
>
<l:testBean value="testing xml"/>
</r:root>
+--
* Parse the xml
+--
FooBarParser p = new FooBarParser();
p.parseFile("foobar/example.xml");
TestBeanRoot root = p.getRoot();
+--

View file

@ -23,56 +23,57 @@
Validation
Schema validation is just new feature and work in progress to have it support all different xml language formats.
With x4o there are currently two options howto validate your documents, it depends if the language is extended.
* Validating parser
+--
TestParser parser = new TestParser();
parser.setProperty(X4OLanguagePropertyKeys.VALIDATION_INPUT, true);
parser.parse(...);
+--
Schema validation is just an new feature and work in progress.
There are still option being added so it can support all different xml languages.
With x4o there are currently two options to validate your documents, it depends if the language is extended at runtime or not.
The actual grammer validation is done by the java jaxp parser.
* Generate static languages
Store the generated xsd files in the (resource)classpath of project in META-INF/<language>/<ns-schemaResource>.
When the xml language is not dynamicly extended at runtime all the schemas can be generated in the build process
and be included in the jar file.
These generated xsd files are stored in the (resource)classpath of project in META-INF/foobar/foobar-1.0.xsd.
Then the validating parser will find the schema resources while loading the namespace contexts.
These schemas can be created or updates while package project or update manually by build script of profile.
For example see the profile in the pom.xml of the x4o-plugin-ant-schema module.
For example see the profile in the pom.xml of the x4o-plugin-ant-schema.
* Validating parser
Use validating parser
+--
TestParser parser = new TestParser();
parser.setProperty(X4OLanguagePropertyKeys.VALIDATION_INPUT, true);
parser.parse(...);
TestParser parser = new TestParser();
parser.setProperty(X4OLanguagePropertyKeys.VALIDATION_INPUT, true);
parser.parse(...);
+--
* Generate dynamic languages
Generate the xsd files while all the language extensions are loaded in the classpath.
Use the embedded java program in the x4o-core;
+--
java -cp '...jar:x4o-core.jar' org.x4o.xml.eld.xsd.X4OLanguageEldXsdWriter -path /tmp -class org.foo.bar.TestParserSupport
java -cp '...jar:x4o-core.jar' org.x4o.xml.eld.xsd.X4OLanguageEldXsdWriter -path /tmp -class org.foo.bar.TestParserSupport
+--
Or use the ant task in the x4o-plugin-ant-schema;
+--
<taskdef name="eldXsdWriter" classname="org.x4o.plugin.ant.eld.xsd.EldXsdWriterTask"/>
<eldXsdWriter destdir="/tmp" supportclass="org.foo.bar.TestParserSupport"/>
<taskdef name="eldXsdWriter" classname="org.x4o.plugin.ant.eld.xsd.EldXsdWriterTask"/>
<eldXsdWriter destdir="/tmp" supportclass="org.foo.bar.TestParserSupport"/>
+--
* Validating parser
Use validating parser
+--
TestParser parser = new TestParser();
parser.setProperty(X4OLanguagePropertyKeys.VALIDATION_INPUT, true);
parser.setProperty(X4OLanguagePropertyKeys.VALIDATION_SCHEMA_PATH, "/tmp");
parser.parse(...);
TestParser parser = new TestParser();
parser.setProperty(X4OLanguagePropertyKeys.VALIDATION_INPUT, true);
parser.setProperty(X4OLanguagePropertyKeys.VALIDATION_SCHEMA_PATH, "/tmp");
parser.parse(...);
+--
Note; In future there will be an automatic schema generation option for dynamicly defined langauges so that parser can
be set always on full validating.