From Documentation

Jump to: navigation, search

  1. Uses the XML component set (
  2. Maps the file extension to ZK Loader
  3. Maps the file extension to the XML component set

Use the XML Component Set,

The XML component set (aka., the XML language, in ZK terminology) is used to generate XML output. Unlike the XUL or XHTML component sets, all unknown[1] tags in a ZUML page are assumed to belong the Native namespace ( rather than throwing an exception. ZK generates them directly to the output without instantiating a ZK component for each of them.

The following is an example that generates the SVG output. It looks very similar to the XML output you want to generate, except you can use zscript, EL expressions, macro components and other ZK features.


 <?page contentType="image/svg+xml;charset=UTF-8"?>
 <svg width="100%" height="100%" version="1.1" xmlns="[]"
     String[] bgnds = {"purple", "blue", "yellow"};
     int[] rads = {30, 25, 20};
     <circle style="fill:${each}" z:forEach="${bgnds}"

The generated output will be

<svg xmlns="" width="100%" height="100%"
	<circle style="fill:purple" cx="80" cy="50" r="30">
	<circle style="fill:blue" cx="75" cy="45" r="25">
	<circle style="fill:yellow" cx="70" cy="40" r="20">


  • The content type is specified with the page directive. For SVG, it is image/svg+xml. The xml processing instruction (<?xml?>) and DOCTYPE of the output are also specified in the page directive. Refer to the Developer's Reference for more about the page directive.
  • All tags in this example, such as svg and circle, are associated with a namespace ( that is unknown to ZK Loader. Thus, they are assumed to belong the Native namespace. They are output directly rather than instantiating a ZK component for each of them. Refer to the Native Namespace section int the ZUML with the XUL Component Set chapter for more about the Native namespace.
  • To use zscript, forEach and other ZK specific features, you have to specify the ZK namespace (

Maps the File Extension to ZK Loader

To let ZK Loader process the file, you have to associate it with the ZK Loader in WEB-INF/web.xml. In this example, we map all files with the .svg extension to ZK Loader[2]:


Maps the File Extension to the XML Component Set

Unless the file extension is .xml, you have to associate it with the XML component set (aka., the XML language) explicitly in WEB-INF/zk.xml. In this example, we map .svg to the XML component set:


where xml is the language name of the XML component set ( Thus, when ZK Loader parses a file with the .svg extension, it knows the default language is the XML component set.

  1. By the unknown tag we mean a tag that is not associated with a namespace, or the namespace is unknown.
  2. We assume ZK Loader (zkLoader) is mapped to org.zkoss.zk.ui.http.DHtmlLayoutServlet.

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