Mix With Another Markup Language"

From Documentation
m (Created page with '{{ZKDevelopersGuidePageHeader}} To mix with another markup language, you have to use <tt>xmlns</tt> to specify the correct namespace. <source lang="xml" > <window xmlns:h="htt…')
 
m (correct highlight (via JWB))
 
Line 1: Line 1:
 
{{ZKDevelopersGuidePageHeader}}
 
{{ZKDevelopersGuidePageHeader}}
  
To mix with another markup language, you have to use <tt>xmlns</tt> to specify the correct namespace.
+
To mix with another markup language, you have to use <code>xmlns</code> to specify the correct namespace.
  
 
<source lang="xml" >
 
<source lang="xml" >
Line 11: Line 11:
 
</source>
 
</source>
 
   
 
   
For the XHTML components, the <tt>onClick</tt> and <tt>onChange</tt> attributes are conflicts with ZK's attributes. To resolve, you have to use the reserved namespace, <tt>http://www.zkoss.org/2005/zk</tt>, as follows.
+
For the XHTML components, the <code>onClick</code> and <code>onChange</code> attributes are conflicts with ZK's attributes. To resolve, you have to use the reserved namespace, <code>http://www.zkoss.org/2005/zk</code>, as follows.
  
 
<source lang="xml" >
 
<source lang="xml" >
Line 37: Line 37:
 
</source>
 
</source>
  
* <tt>xmlns="http://www.w3.org/1999/xhtml"</tt> specifies a namespace called <tt>http://www.w3.org/1999/xhtml</tt>, and use it as the default namespace.
+
* <code>xmlns="http://www.w3.org/1999/xhtml"</code> specifies a namespace called <code>http://www.w3.org/1999/xhtml</code>, and use it as the default namespace.
* <tt><html></tt> specifies an element called <tt>html</tt> from the default namespace, i.e., <tt>http://www.w3.org/1999/xhtml</tt> in this example.
+
* <code><html></code> specifies an element called <code>html</code> from the default namespace, i.e., <code>http://www.w3.org/1999/xhtml</code> in this example.
* <tt>xmlns:x="[http://www.potix.com/2005/zul http://][http://www.potix.com/2005/zul www.zkoss.org/2005/zul]"</tt> specifies a namespace called [http://www.potix.com/2005/zul http://www.zkoss.org/2005/zul], and use x to represent this namespace.
+
* <code>xmlns:x="[http://www.potix.com/2005/zul http://][http://www.potix.com/2005/zul www.zkoss.org/2005/zul]"</code> specifies a namespace called [http://www.potix.com/2005/zul http://www.zkoss.org/2005/zul], and use x to represent this namespace.
* <tt><x:window/></tt> specifies an element called <tt>window</tt> from the name space called [http://www.potix.com/2005/zul http://][http://www.potix.com/2005/zul www.zkoss.org/2005/zul].
+
* <code><x:window/></code> specifies an element called <code>window</code> from the name space called [http://www.potix.com/2005/zul http://][http://www.potix.com/2005/zul www.zkoss.org/2005/zul].
  
  
In this example, the <tt>onClick</tt> attribute is a ZHTML's attribute to specify JavaScript codes to run at the browser. On the other hand, the <tt>zk:onClick</tt> is a reserved attribute for specify a ZK event handler.
+
In this example, the <code>onClick</code> attribute is a ZHTML's attribute to specify JavaScript codes to run at the browser. On the other hand, the <code>zk:onClick</code> is a reserved attribute for specify a ZK event handler.
  
Notice that the namespace prefix, <tt>zk</tt>, is optional for the <tt>zscript</tt> element, because ZHTML has no such element and ZK has enough information to determine it.
+
Notice that the namespace prefix, <code>zk</code>, is optional for the <code>zscript</code> 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 <tt>window</tt> component, because it is from a different component set.
+
Also notice that you have to specify the XML namespace for the <code>window</code> component, because it is from a different component set.
  
 
=== Auto-completion with Schema ===
 
=== Auto-completion with Schema ===
Line 58: Line 58:
 
</source>
 
</source>
 
   
 
   
In addition to downloading from [http://www.zkoss.org/2005/zul/zul.xsd http://www.zkoss.org/2005/zul/zul.xsd], you can find <tt>zul.xsd</tt> under the <tt>dist/xsd</tt> directory in the ZK binary distribution.
+
In addition to downloading from [http://www.zkoss.org/2005/zul/zul.xsd http://www.zkoss.org/2005/zul/zul.xsd], you can find <code>zul.xsd</code> under the <code>dist/xsd</code> directory in the ZK binary distribution.
  
  
  
 
{{ ZKDevelopersGuidePageFooter}}
 
{{ ZKDevelopersGuidePageFooter}}

Latest revision as of 10:36, 19 January 2022

Stop.png This documentation is for an older version of ZK. For the latest one, please click here.


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="http://www.w3.org/1999/xhtml"
      xmlns:x="[http://www.potix.com/2005/zul 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>
</html>


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.

Auto-completion with Schema

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.




Last Update : 2022/01/19

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