As stated before, each set of components is associated with an unique namespace. However, developers might develop or use additional components from 3rd party, so here we list only the namespaces that are shipped with the ZK distribution.
Namespaces |
---|
The namespace of the XUL component set. |
http://www.w3.org/1999/xhtml The namespace of the XHTML component set. |
http://www.zkoss.org/2005/zk The ZK namespace. It is the reserved namespace for specifying ZK specific elements and attributes. |
http://www.zkoss.org/2005/zk/native The Native namespace. It is the reserved namespace for specifying inline elements. Refer to the Work with HTML Tags section for details. |
native:URI-of-another-namespace Alternative way to specify the Native namespace. In addition to identifying a tag belonging to the Native namespace, the namespace following native: is generated to the output sent to the client. Refer to the Work with HTML Tags section for details. |
http://www.zkoss.org/2005/zk/annotation The Annotation namespace. It is the reserved namespace for specifying the annotations. Refer to the Annotations section for details |
It is optional to specify namespaces in ZUML pages, until there are conflicts. ZK determined which namespace to use by examining the extension of a ZUML page. For the .zul and .xul extensions, the namespace of XUL is assumed. For html, xhtml and zhtml, the namespace of XHTML is assumed.
To mix with another markup language, you have to use xmlns to specify the correct namespace.
<window xmlns:h="http://www.w3.org/1999/xhtml"> <h:div> <button/> </h:div> </window>
For the XHTML components, the onClick and onChange attributes are conflicts with ZK's attributes. To resolve, you have to use the reserved namespace, http://www.zkoss.org/2005/zk, as follows.
<html xmlns:x="http://www.zkoss.org/2005/zul" xmlns:zk="http://www.zkoss.org/2005/zk"> <head> <title>ZHTML Demo</title> </head> <body> <script type="text/javascript"> function woo() { //running at the browser } </script> <zk:zscript> void addItem() { //running at the server } </zk:zscript> <x:window title="HTML App"> <input type="button" value="Add Item" onClick="woo()" zk:onClick="addItem()"/> </x:window> </body>
In this example, the onClick attribute is a ZHTML's attribute to specify JavaScript codes to run at the browser. On the other hand, the zk:onClick is a reserved attribute for specify a ZK event handler.
Notice that the namespace prefix, zk, is optional for the zscript element, because ZHTML has no such element and ZK has enough information to determine it.
Also notice that you have to specify the XML namespace for the window component, because it is from a different component set.