dk.brics.xact.operations
Class XHTMLIndentation
java.lang.Object
dk.brics.xact.operations.XHTMLIndentation
- All Implemented Interfaces:
- XMLIndentation
public class XHTMLIndentation
- extends Object
- implements XMLIndentation
Indents XHTML output for the purpose of making it readible as possible, while attempting
not to change its rendering (see note below) using the following rules:
The indentation uses four whitespaces per level and the system
property line.separator as the linebreaker.
Please note that CSS can cause other XHTML elements to become whitespace-sensitive, so this
is not generally a sound indentation for XHTML (ie. it can change the layout of the page).
Therefore, this is mainly intended for debugging.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XHTMLIndentation
public XHTMLIndentation()
getIndentation
public String getIndentation()
- Description copied from interface:
XMLIndentation
- Returns the indentation string to prefix every line for each level of indentation.
- Specified by:
getIndentation
in interface XMLIndentation
- Returns:
- indentation string
getIndentType
public XMLIndentation.IndentType getIndentType(Element element)
- Description copied from interface:
XMLIndentation
- Decide whether indentation should be increased when printing
the children of the specified element.
In XHTML, elements such as <a> and <u> should not be indented
because they are sensitive to leading and trailing whitespace.
- Specified by:
getIndentType
in interface XMLIndentation
- Parameters:
element
- an XML element about to be printed
- Returns:
- true if indentation should be enabled
getLineBreak
public String getLineBreak()
- Description copied from interface:
XMLIndentation
- Returns the string used to represent linebreaks. Typically \r\n, \r or \n.
- Specified by:
getLineBreak
in interface XMLIndentation
- Returns:
- a string
isWhitespaceSensitive
public boolean isWhitespaceSensitive(Element element)
- Description copied from interface:
XMLIndentation
- Returns true if the specified element is sensitive to repeated whitespace.
In XHTML, elements such as <pre> and <textarea> are sensitive
to repeated whitespace, though any element can be made sensitive through CSS.
- Specified by:
isWhitespaceSensitive
in interface XMLIndentation
- Parameters:
element
- an XML element about to be printed
- Returns:
- true if element is whitespace-sensitive
Copyright © 2005-2011 Aarhus University.