XML Namespaces

From Documentation
Revision as of 06:37, 3 December 2010 by Tomyeh (talk | contribs) (→‎Languages)

In a ZUML document, a XML namespace is used to identify either a special functionality or a component set. We call the former as a standard namespace, while the later as a language.

Standard Namespaces

For example, the client namespace is used to identify that a XML attribute shall be interpreted as a client-side control.

In the following example, w:onFocus is a client-side listener since w: is specified, while onChange is

<combobox xmlns:w="client" w:onFocus="this.open()" onChange="doOnChange()"/>

The native namespace is another standard namespace used to indicate a XML element shall be generated natively, rather than a component. For example,

<n:table xmlns:n="native">
  <n:tr>
    <n:td>Username</n:td>
    <n:td><textbox/></n:td>
  </n:tr>
  <n:tr>
    <n:td>Password</n:td>
    <n:td><textbox type="password"/></n:td>
  </n:tr>
</n:table>

where n:table, n:tr and n:td are native, i.e., they are generated directly to the client without creating a component for each of them.

For more information, please refer to ZUML Reference.

Languages

A language (LanguageDefinition) is a collection of component definitions. It is also known as a component set.

For example, Window, Button and Combobox all belong to the same language called xul/html. It is a ZK variant of XUL (and also known as zul).

Component designers are free to designate a component definition to any component set they prefer, as long as there is no name conflict.

When parsing a ZUML document, ZK Loader have to decide the language that a XML element is associated, such that the correct component definition (ComponentDefinition) can be resolved. For example, in the following example, ZK needs to know window belongs to the xul/html language, so its component definition can be retrieved correctly.

<window>

ZK Loader first decides the default language from the extension. For example foo.zul implies the ZUL langauge. The default language is used if a XML element is not specified with any namespace. For example, window in the previous example will be considered as a component definition of the ZUL langauge.

If the extension is zhtml (such as foo.zhtml), the default language will be XHTML. Thus, window in the previous example will be interpreted incorrectly. To solve it, you could specify the XML namespace explicitly.

<!-- foo.zhtml -->
<p> <!-- assumed from the XHTML language -->
    <u:window xmlns:u="zul"/> <!-- ZK Loader will search the ZUL language instead -->
</p>

Version History

Last Update : 2010/12/03


Version Date Content
     



Last Update : 2010/12/03

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.