前に書いたように、どのコンポーネントセットもそれぞれ一つの(唯一の)ネーム空間と関連しています。しかし、ディベロッパーはサードパーティーのコン ポーネントを使用したり、発展させたりするかもしれません。ここにZKパッケージにあるネーム空間だけをリストアップします。
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 |
他の名前と重ならない限り、ZUMLページ中でネーム空間を自分で指定できます。ZKはZUMLページの拡張子によって、どのネーム空間を使うかを決めます。.zulと.xul拡張はXULのネーム空間が割り当てられます。html、xhtml、zhtmlはXHTMLのネーム空間が割り当てられます。
他のマークアップ言語と混在に使うために、xmlnsを使用し、正しいネーム空間を指定しなければいけません。
<window xmlns:h="http://www.w3.org/1999/xhtml"> <h:div> <button/> </h:div> </window>
XHTMLコンポーネントではonClick、onChange属性はZKの属性と競合します。解決するためには、確保されたネーム空間http://www.zkoss.org/2005/zkを以下のように使用しなければなりません。
<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>
この例中では、onClick属性はZHTMLの属性です。ブラウザで動作するJavaScriptコードを指定します。一方で、zk:onClickはZKイベントハンドラを指定するために確保された属性です。
ZHTMLはzscript要素を持たないので、プログラマーがzscript要素にネーム空間のプレフィックスzkを使うかどうか決める事ができます。またZKが十分な情報を持っているのでプレフィックスが無くても判断できます。
またコンポーネントセットとは異なったものなのでwindowコンポーネントにはXMLネーム空間を指定しなければならないことに注意してください。