The language definition is a XML file definition a new language, which includes component definitions and other language features.
The syntax of the language definition is similar to the language addon except the location and the headers are a bit different.
The language definition must be named lang.xml and placed at the /metainfo/zk directory accessible by the classpath.
[Required]
<language-name>xul/html</language-name>
Specified the language name that uniquely identifies this langauge.
[Required]
<<device-type>ajax</device-type>
Specified the device type, such as ajax, xml, mil and hil.
[Required]
<namespace>http://www.zkoss.org/2005/zul</namespace>
Specified the namespace that also uniquely identifies this language.
[Required; Multiple]
<extension>zul</extension> <extension>xul</extension>
Specified the file extension that shall be considered as using this language. For example, if zul is specified, this language will be used as the default language for all files with the .zul extension. Of course, the file can change the language later with the page directive.
[Optional[18]]
<version> <version-class>org.zkoss.zul.Version</version-class> <version-uid>3.0.5</version-uid> <zk-version>3.0.0</zk-version><!-- or later → </version>
There are two parts: language version and ZK version. Language version is specified in version-uid element. In certain environments, it is possible to have several versions of JAR file containing the same set of component definitions[19]. To ensure the correct XML file is loaded, you have to specify a class carrying the version. The class must have a static data member called UID as shown below.
public class Version {
public static final String UID = "3.0.5";
}
Then, ZK will compare UID with the value specified in version-uid, and the language is ignored if not matched – it means the XML file is not from the same JAR file being loaded.
ZK Version that this language requires is specified in the zk-version element. The language is ignored if ZK installed is an older version.
[Optional][Multiple]
<javascript src="~./js/zk/zk.js.dsp" charset="UTF-8"/>
Specifies a JavaScript file that must be loaded when a ZUML page is sent to the browser. It is actually generated inside HTML HEAD tag.
[Optional][Multiple]
<stylesheet href="~./zul/css/norm*.css.dsp*" type="text/css"/>
Specifies a CSS file that must be loaded when a ZUML page is sent to the browser. It is actually generated inside HTML HEAD tag.
[Optional][Multiple]
<zscript language="Java">
void alert(String m) {
Messagebox.show(m);
}
</zscript>
Specifies a snippet of zscript codes that will be evaluated before ZK evaluates the zscript codes embedded in a ZUML page. The snippet is evaluated only once. If you want it to be evaluated each time the embedded zscript codes is evaluated, you can specify the each-time attribute as follows.
<zscript language="Groovy" each-time="true"> import java.util.* </zscript>
[Optional][Multiple]
<mold> <mold-name>desktop</mold-name> <mold-uri>~./zul/html/desktop.dsp</mold-uri> </mold>
Specifies the URL used to render a desktop or a page. Only three mold names are accepeted: desktop, page and complete. The desktop mold is used if a ZK page is standalone, i.e., not included by another page. The page mold is used if a ZK page is included by another page. The complete mold is used if a page is declared to be complete. , i.e., the complete attribute of the page directive is true; refer to the Developer's Reference.
[Required]
<label-template> <component-name>label</component-name> <component-attribute>value</component-attribute> </label-template>
Specifies the component that is used to represent a label. When ZK loader encounters a piece of text, it converts it to a component specified here. For example, based on the label-template example listed above, the following codes
<window> Test </window>
is equivalent to
<window> <label value="Test"/> </window>
[Optional]
<label-template> <component-name>label</component-name> <component-attribute>value</component-attribute> <raw/> </label-template>
Specifies whether the language prefer to use the raw labels.
By raw labels we mean the text shall not be trimmed and shall be generated directly to the output (rather than wrapping with, say, SPAN).
For example, the ZHTML and ZML languages specify this option, while the ZUL language doesn't.
[Required]
<macro-template> <macro-class>org.zkoss.zk.ui.HtmlMacroComponent</macro-class> <macro-uri>~./zul/html/macro.dsp</macro-uri> </macro-template>
Specifies the class used to represent a macro component, and the URI used to render it.
The class specified in the macro-class element must implement the org.zkoss.zk.ui.ext.Macro interface.