Package org.eclipse.lemminx.extensions.contentmodel.utils

## Class XMLGenerator

- java.lang.Object
- - org.eclipse.lemminx.extensions.contentmodel.utils.XMLGenerator

    public class XMLGenerator
    extends Object

XML generator used to generate an XML fragment with formatting from a given element declaration (XML Schema element declaration, DTD element, etc).

### Constructor Summary

Constructors
`XMLGenerator​(SharedSettings sharedSettings, boolean autoCloseTags, String whitespacesIndent, String lineDelimiter, boolean canSupportSnippets, int maxLevel, DOMNode node)`
`XMLGenerator​(SharedSettings sharedSettings, String whitespacesIndent, String lineDelimiter, boolean canSupportSnippets, int maxLevel)` XML generator constructor.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static org.eclipse.lsp4j.MarkupContent` `createMarkupContent​(CMAttributeDeclaration cmAttribute, String attributeValue, CMElementDeclaration ownerElement, ISharedSettingsRequest support)` Returns a markup content for attribute value documentation and null otherwise.
`static org.eclipse.lsp4j.MarkupContent` `createMarkupContent​(CMAttributeDeclaration cmAttribute, CMElementDeclaration ownerElement, ISharedSettingsRequest request)` Returns a markup content for attribute name documentation and null otherwise.
`static org.eclipse.lsp4j.MarkupContent` `createMarkupContent​(CMElementDeclaration cmElement, String textContent, ISharedSettingsRequest support)` Returns a markup content for element text documentation and null otherwise.
`static org.eclipse.lsp4j.MarkupContent` `createMarkupContent​(CMElementDeclaration cmElement, ISharedSettingsRequest support)` Returns a markup content for element documentation and null otherwise.
`String` `generate​(Collection<CMAttributeDeclaration> attributes, String tagName)`
`String` `generate​(CMElementDeclaration elementDeclaration, String prefix, boolean generateEndTag)` Returns the XML generated from the given element declaration.
`String` `generate​(CMElementDeclaration elementDeclaration, String prefix, boolean generateEndTag, boolean generateOnlyChildren, int level, boolean generateOnlyRequired)` Returns the XML generated from the given element declaration given option to generate only children and only required elements.
`static String` `generateAttributeValue​(String defaultValue, Collection<String> enumerationValues, boolean canSupportSnippets, int snippetIndex, boolean withQuote, SharedSettings sharedSettings)` Creates the string value for a CompletionItem TextEdit Can create an enumerated TextEdit if given a collection of values.
`static String` `generateDocumentation​(String documentation, String schemaURI, boolean html)` Returns a properly formatted documentation string with source.
`String` `generateMissingElements​(ContentModelManager contentModelManager, DOMElement element, boolean generateOnlyRequired)`
`String` `getLineDelimiter()` Returns the line delimiter.
`String` `getWhitespacesIndent()` Returns the whitespaces indentation.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### XMLGenerator

    public XMLGenerator​(SharedSettings sharedSettings,
                        String whitespacesIndent,
                        String lineDelimiter,
                        boolean canSupportSnippets,
                        int maxLevel)

XML generator constructor.

Parameters:
  `sharedSettings` - the settings containing formatting options (uses spaces or tabs for indentation, etc) and preferences
  `whitespacesIndent` - the whitespaces to use to indent XML children elements.
  `lineDelimiter` - the line delimiter to use when several XML elements must be generated.
  `canSupportSnippets` - true if snippets can be supported and false otherwise.

#### XMLGenerator

    public XMLGenerator​(SharedSettings sharedSettings,
                        boolean autoCloseTags,
                        String whitespacesIndent,
                        String lineDelimiter,
                        boolean canSupportSnippets,
                        int maxLevel,
                        DOMNode node)

### Method Detail

#### generateMissingElements

    public String generateMissingElements​(ContentModelManager contentModelManager,
                                          DOMElement element,
                                          boolean generateOnlyRequired)

#### getLineDelimiter

    public String getLineDelimiter()

Returns the line delimiter.

Returns:
  the line delimiter.

#### getWhitespacesIndent

    public String getWhitespacesIndent()

Returns the whitespaces indentation.

Returns:
  the whitespaces indentation.

#### generate

    public String generate​(CMElementDeclaration elementDeclaration,
                           String prefix,
                           boolean generateEndTag)

Returns the XML generated from the given element declaration.

Parameters:
  `elementDeclaration` -
  `prefix` -
Returns:
  the XML generated from the given element declaration.

#### generate

    public String generate​(CMElementDeclaration elementDeclaration,
                           String prefix,
                           boolean generateEndTag,
                           boolean generateOnlyChildren,
                           int level,
                           boolean generateOnlyRequired)

Returns the XML generated from the given element declaration given option to generate only children and only required elements.

Parameters:
  `elementDeclaration` -
  `prefix` -
  `generateEndTag` -
  `level` - the level at which the first element will be generated at
  `generateOnlyChildren` - true if only is children of the given element is to be generated
  `generateOnlyRequired` - true if only the required elements is to be generated
Returns:
  the XML generated from the given element declaration given option to generate only children.

#### generate

    public String generate​(Collection<CMAttributeDeclaration> attributes,
                           String tagName)

#### generateAttributeValue

    public static String generateAttributeValue​(String defaultValue,
                                                Collection<String> enumerationValues,
                                                boolean canSupportSnippets,
                                                int snippetIndex,
                                                boolean withQuote,
                                                SharedSettings sharedSettings)

Creates the string value for a CompletionItem TextEdit Can create an enumerated TextEdit if given a collection of values.

#### generateDocumentation

    public static String generateDocumentation​(String documentation,
                                               String schemaURI,
                                               boolean html)

Returns a properly formatted documentation string with source. If there is no content then null is returned.

Parameters:
  `documentation` -
  `schemaURI` -
Returns:

#### createMarkupContent

    public static org.eclipse.lsp4j.MarkupContent createMarkupContent​(CMElementDeclaration cmElement,
                                                                      ISharedSettingsRequest support)

Returns a markup content for element documentation and null otherwise.

Parameters:
  `cmElement` -
  `support` -
Returns:
  a markup content for element documentation and null otherwise.

#### createMarkupContent

    public static org.eclipse.lsp4j.MarkupContent createMarkupContent​(CMAttributeDeclaration cmAttribute,
                                                                      CMElementDeclaration ownerElement,
                                                                      ISharedSettingsRequest request)

Returns a markup content for attribute name documentation and null otherwise.

Parameters:
  `cmAttribute` - the attribute declaration
  `ownerElement` - the owner element declaration
  `request` - the request
Returns:
  a markup content for attribute name documentation and null otherwise.

#### createMarkupContent

    public static org.eclipse.lsp4j.MarkupContent createMarkupContent​(CMAttributeDeclaration cmAttribute,
                                                                      String attributeValue,
                                                                      CMElementDeclaration ownerElement,
                                                                      ISharedSettingsRequest support)

Returns a markup content for attribute value documentation and null otherwise.

Parameters:
  `cmAttribute` -
  `attributeValue` -
  `ownerElement` -
  `support` -
Returns:
  a markup content for attribute value documentation and null otherwise.

#### createMarkupContent

    public static org.eclipse.lsp4j.MarkupContent createMarkupContent​(CMElementDeclaration cmElement,
                                                                      String textContent,
                                                                      ISharedSettingsRequest support)

Returns a markup content for element text documentation and null otherwise.

Parameters:
  `cmElement` - element declaration.
  `textContent` - the text content.
  `support` - markup kind support.
Returns:
  a markup content for element text documentation and null otherwise.