01: /* XMLFns.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Thu Mar 31 14:16:40 2005, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2005 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.web.fn;
20:
21: /**
22: * Utilities to manipulate XML/HTML for EL.
23: *
24: * @author tomyeh
25: */
26: public class XMLFns {
27: /** Generates an attribute for HTML/XML.
28: * If val is null or empty (if String), nothing is generated.
29: */
30: public static final String attr(String name, Object val) {
31: if (val == null
32: || (val instanceof String && ((String) val).length() == 0))
33: return "";
34:
35: return " " + name + "=\"" + val + '"';
36: }
37: }
|