DOMFormatOptions Class Reference
List of all members.
Detailed Description
This class encapsulates information on how a document should be formatted when being converted to a string or written to a file.
Currently there are five options:
- indent string Determines which string is used for indenting, the default is tab (\t), can be set to the empty string for no indentation at all
- use newlines Determines if there will be any line breaks between nodes, the output will be totally unintelligible if newlines are not used, but it will be more compact, which may be desired
- normalize whitespace This setting will make the formatter normalize the whitespace of text nodes before their contents are included (see DOMText#dataNormalizeWhitespace: for more info).
- include prolog This setting applies only when the document is written to a file, if set to YES, the XML prolog (<?xml version="1.0"?>) will be written at the top of the file, the encoding will also be specified.
- inline content of elements This setting takes a set of element names (as strings), when encountering these elements, the formatter will not include newlines before or after the element. Elements in mixed content (elements that have text node siblings) will always be inlined. Example (the element "string" has inlined contents):
<test>
<string>It is usually not this cold in may</string>
</test>
This class also encapsulates some logic determining how these options should affect the result. The formatter will query it's options object about when to add a newline, add indentation, and so forth.
Member Function Documentation
| - (BOOL) elementShouldHaveInlinedContent: |
|
(NSString *) |
elementName |
|
|
|
|
|
Returns options object with the default options set.
The default options are: - indent string: "\t"
- use newlines: YES
- include prolog: YES
- normalize whitespace: YES
- don't inline the contents of any elements (except those in mixed content)
|
| - (NSString *) indentString |
|
|
|
|
|
| - (void) inlineContentOfElements: |
|
(NSSet *) |
elementNames |
|
|
|
|
|
The named elements will have their content inlined, that is, there will be no space between the end of the tag and the content.
Elements in mixed content (elements that have text node siblings) will always be inlined.
- Parameters:
-
| elementNames | The names of the elements that should be inlined in text (ex. ["span", "bold", "name"]), an NSSet of NSStrings |
|
| - (BOOL) normalizeWhitespace |
|
|
|
|
|
| - (void) setIncludeProlog: |
|
(BOOL) |
prolog |
|
|
|
| - (void) setIndentString: |
|
(NSString *) |
indent |
|
|
|
| - (void) setNormalizeWhitespace: |
|
(BOOL) |
normalize |
|
|
|
| - (void) setUsesNewlines: |
|
(BOOL) |
newlines |
|
|
|
| - (BOOL) shouldHaveNewlineAfterNode: |
|
(id< DOMNode >) |
node |
|
|
|
|
|
In these cases there should NOT be a newline after: - Nodes whose parent is in mixed content.
- Nodes in mixed content (unless it is the last one).
- Nodes with a parent that has been set to have inlined content.
|
| - (BOOL) shouldHaveNewlineBeforeNode: |
|
(id< DOMNode >) |
node |
|
|
|
|
|
In these cases there should NOT be a newline before: - Nodes whose parent is in mixed content.
- Nodes with a parent that has been set to have inlined content.
|
| - (BOOL) shouldIndentNode: |
|
(id< DOMNode >) |
node |
|
|
|
|
|
Decides which nodes to indent, based on rules and options.
All nodes should be indented, except for: - In mixed content nodes should not be indented, except for the first sibling, which should be indented if the parent is not in mixed content.
- Text node children of elements that should have inlined text
|