dk.brics.xact.operations
Interface XMLIndentation

All Known Implementing Classes:
XHTMLIndentation

public interface XMLIndentation

Specifies how to indent an XML template or document. The default implementation NEVER will disable all indentation and is recommended for production use. Other available implementations are XHTML and ALWAYS, though one can provide his own implementation if necessary.


Nested Class Summary
static class XMLIndentation.IndentType
           
 
Field Summary
static XMLIndentation ALWAYS
          Implementation that indents all elements using four whitespaces per level and uses the system property line.separator as line separator.
static XMLIndentation NEVER
          Default implementation that ensures no indentation will be performed.
static XHTMLIndentation XHTML
          An instance of of the XHTMLIndentation class, provided here for convenience.
 
Method Summary
 String getIndentation()
          Returns the indentation string to prefix every line for each level of indentation.
 XMLIndentation.IndentType getIndentType(Element element)
          Decide whether indentation should be increased when printing the children of the specified element.
 String getLineBreak()
          Returns the string used to represent linebreaks.
 boolean isWhitespaceSensitive(Element element)
          Returns true if the specified element is sensitive to repeated whitespace.
 

Field Detail

ALWAYS

static final XMLIndentation ALWAYS
Implementation that indents all elements using four whitespaces per level and uses the system property line.separator as line separator.


NEVER

static final XMLIndentation NEVER
Default implementation that ensures no indentation will be performed.


XHTML

static final XHTMLIndentation XHTML
An instance of of the XHTMLIndentation class, provided here for convenience.

Method Detail

getIndentation

String getIndentation()
Returns the indentation string to prefix every line for each level of indentation.

Returns:
indentation string

getIndentType

XMLIndentation.IndentType getIndentType(Element element)
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.

Parameters:
element - an XML element about to be printed
Returns:
true if indentation should be enabled

getLineBreak

String getLineBreak()
Returns the string used to represent linebreaks. Typically \r\n, \r or \n.

Returns:
a string

isWhitespaceSensitive

boolean isWhitespaceSensitive(Element element)
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.

Parameters:
element - an XML element about to be printed
Returns:
true if element is whitespace-sensitive


Copyright © 2005-2011 Aarhus University.