Namespaces are a simple and straightforward way to distinguish names used in XML documents. ZK uses XML namespaces to distinguish the component name, such that it is OK to have two components with the same name as long as they are in different namespace. In other words, ZK uses a XML namespace to represent a component set, such that developers could mix two or more component sets in the same page, as depicted below.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:x="http://www.zkoss.org/2005/zul" xmlns:zk="http://www.zkoss.org/2005/zk"> <head> <title>ZHTML Demo</title> </head> <body> <h1>ZHTML Demo</h1> <table> <tr> <td><x:textbox/></td> <td><x:button label="Now" zk:onClick="addItem()"/></td> </tr> </table> <zk:zscript> void addItem() { } </zk:zscript> </body> </html>
where
xmlns:x="http:// www.zkoss.org/2005/zul" specifies a namespace called http://www.zkoss.org/2005/zul, and use x to represent this namespace.
xmlns="http://www.w3.org/1999/xhtml" specifies a namespace called http://www.w3.org/1999/xhtml, and use it as the default namespace.
<html> specifies an element called html from the default namespace, i.e., http://www.w3.org/1999/xhtml in this example.
<x:textbox/> specifies an element called textbox from the name space called http:// www.zkoss.org/2005/zul.
Many IDEs, such Eclipse, supports auto-completion if XML schema is specified as follows.
<window xmlns="http://www.zkoss.org/2005/zul" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
In addition to downloading from http://www.zkoss.org/2005/zul/zul.xsd, you can find zul.xsd under the dist/xsd directory in the ZK binary distribution.