public final class XhtmlUtil extends java.lang.Object
This uses JDOM2 as its backing implementation.
To generate a single element, an Element with PCDATA content, and then embed the latter in the former:
Element div = XhtmlUtil.element(XHTML.div);
Element p = XhtmlUtil.element(XHTML.p,"Some content");
div.addContent(p);
There is also a convenient link and link target constructor methods:
Element link = XhtmlUtil.link("hrefValue","linkText");
Element target = XhtmlUtil.target("targetIdValue","linkText");
| Modifier and Type | Field and Description | |
|---|---|---|
static org.jdom2.output.Format |
EXPAND_EMPTY_NODES
to print instead of
|
| Modifier and Type | Method and Description |
|---|---|
static org.jdom2.Element |
element(XHTML element)
Return an Element with an element type name matching the parameter.
|
static org.jdom2.Element |
element(XHTML element,
java.lang.String content)
Return an Element with an element type name matching the parameter,
and optional PCDATA (parsed character data, a String) content.
|
static org.jdom2.Element |
img(java.lang.String src,
java.lang.String alt)
Return an XHTML img element with an required 'src' attribute
and optional 'alt' alternative text value.
|
static org.jdom2.Element |
input(java.lang.String type,
java.lang.String name,
java.lang.String value)
Return an XHTML form input element with optional 'type', 'name' and 'value' attributes.
|
static org.jdom2.Element |
link(java.lang.String href,
java.lang.String content)
Return an XHTML link with a required 'href' attribute value and optional link (PCDATA) content.
|
static java.lang.String |
serialize(org.jdom2.Element element)
Serializes the Element to a String using a compact serialization format.
|
static java.lang.String |
serialize(org.jdom2.Element element,
boolean pretty)
Serializes the Element to a String.
|
static java.lang.String |
serialize(org.jdom2.Element element,
org.jdom2.output.Format format)
Serializes the Element to a String.
|
static void |
setClass(org.jdom2.Element element,
java.lang.String classValue) |
static org.jdom2.Element |
target(java.lang.String id,
java.lang.String content)
Return an XHTML link target with a required 'id' attribute value.
|
public static final org.jdom2.output.Format EXPAND_EMPTY_NODES
public static java.lang.String serialize(org.jdom2.Element element)
element - the element to serialize.public static java.lang.String serialize(org.jdom2.Element element, boolean pretty)
element - the element to serialize.pretty - if true, use a pretty whitespace format.public static java.lang.String serialize(org.jdom2.Element element, org.jdom2.output.Format format)
element - the element to serialize.format - custom format used to serialize the Element.public static org.jdom2.Element element(XHTML element)
element - the XHTML element type.public static org.jdom2.Element element(XHTML element, java.lang.String content)
element - the XHTML element type.content - the optional PCDATA content.public static org.jdom2.Element link(java.lang.String href, java.lang.String content)
href - the required 'href' value.content - the optional link (PCDATA) content.public static org.jdom2.Element target(java.lang.String id, java.lang.String content)
id - the required 'id' link target value.public static org.jdom2.Element img(java.lang.String src, java.lang.String alt)
src - the required 'src' value.alt - the optional 'alt' alternative text value.public static org.jdom2.Element input(java.lang.String type, java.lang.String name, java.lang.String value)
type - the optional 'type' value.name - the optional 'name' value.value - the optional 'value' value.public static void setClass(org.jdom2.Element element, java.lang.String classValue)
Copyright (c) 2001-2022 The Apache Software Foundation. All rights reserved.