src/main/java/com/machinezoo/pushmode/dom/DomFormatter.java
public DomFormatter format(DomContent content) {
		if (!extra.isEmpty()) {
			if (!(content instanceof DomElement))
				throw new IllegalArgumentException("Must be an element.");
			/*
			 * When attaching page ID or xmlns, there's a question of where to do it.
			 * It's simpler and more performant to rewrite the root element here
			 * than to implement serialization differently for the root element just to include extra attributes there.
			 */
			DomElement root = (DomElement)content;
			DomElement tagged = new DomElement(root.tagname())
				.key(root.key())
				.id(root.id())
				.set(root.attributes())
				.add(root.children())
				.set(extra);
			for (DomListener listener : root.listeners())
				tagged.subscribe(listener);
			content = tagged;
		}
		if (content != null) {
			/*
			 * DomFragment can appear only as a top-level node in the DOM tree.
			 * We are excluding it from content() method below for performance reasons.
			 */
			if (content instanceof DomFragment)
				children((DomFragment)content);
			else
				content(content);
		}
		return this;
	}
/*
	 * Formatting method is fluent instead of returning the output string.
	 * This is a preparation for future extensions that could produce other kinds of output.
	 * 
	 * It could be called multiple times to concatenate fragments,
	 * but that's an unlikely use case.
	 */
Formatting method is fluent instead of returning the output string.
This is a preparation for future extensions that could produce other kinds of output.

It could be called multiple times to concatenate fragments,
but that's an unlikely use case.
Formatting method is fluent instead of returning the output string . This is a preparation for future extensions that could produce other kinds of output . It could be called multiple times to concatenate fragments but that ' s an unlikely use case .
public DomFormatter format(DomContent content) {
		if (!extra.isEmpty()) {
			if (!(content instanceof DomElement))
				throw new IllegalArgumentException("Must be an element.");
			/*
			 * When attaching page ID or xmlns, there's a question of where to do it.
			 * It's simpler and more performant to rewrite the root element here
			 * than to implement serialization differently for the root element just to include extra attributes there.
			 */
			DomElement root = (DomElement)content;
			DomElement tagged = new DomElement(root.tagname())
				.key(root.key())
				.id(root.id())
				.set(root.attributes())
				.add(root.children())
				.set(extra);
			for (DomListener listener : root.listeners())
				tagged.subscribe(listener);
			content = tagged;
		}
		if (content != null) {
			/*
			 * DomFragment can appear only as a top-level node in the DOM tree.
			 * We are excluding it from content() method below for performance reasons.
			 */
			if (content instanceof DomFragment)
				children((DomFragment)content);
			else
				content(content);
		}
		return this;
	}
public DomFormatter format ( DomContent content ) { if ( ! extra . isEmpty ( ) ) { if ( ! ( content instanceof DomElement ) ) throw new IllegalArgumentException ( "Must be an element." ) ; /*
			 * When attaching page ID or xmlns, there's a question of where to do it.
			 * It's simpler and more performant to rewrite the root element here
			 * than to implement serialization differently for the root element just to include extra attributes there.
			 */ DomElement root = ( DomElement ) content ; DomElement tagged = new DomElement ( root . tagname ( ) ) . key ( root . key ( ) ) . id ( root . id ( ) ) . set ( root . attributes ( ) ) . add ( root . children ( ) ) . set ( extra ) ; for ( DomListener listener : root . listeners ( ) ) tagged . subscribe ( listener ) ; content = tagged ; } if ( content != null ) { /*
			 * DomFragment can appear only as a top-level node in the DOM tree.
			 * We are excluding it from content() method below for performance reasons.
			 */ if ( content instanceof DomFragment ) children ( ( DomFragment ) content ) ; else content ( content ) ; } return this ; }
Formatting method is fluent instead of returning the output string.
Formatting method is fluent instead of returning the output string .