Class XMLElementGenerator
java.lang.Object
org.eclipse.lemminx.extensions.contentmodel.generator.XMLElementGenerator
XML generator used to generate an XML fragment with formatting from a given
element declaration (XML Schema element declaration, DTD element, etc).
-
Constructor Summary
ConstructorsConstructorDescriptionXMLElementGenerator(SharedSettings sharedSettings, boolean autoCloseTags, String whitespacesIndent, String lineDelimiter, boolean canSupportSnippets, int maxLevel, DOMNode node) XMLElementGenerator(SharedSettings sharedSettings, String whitespacesIndent, String lineDelimiter, boolean canSupportSnippets, int maxLevel) XML generator constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.lsp4j.MarkupContentcreateMarkupContent(CMAttributeDeclaration cmAttribute, String attributeValue, CMElementDeclaration ownerElement, ISharedSettingsRequest support) Returns a markup content for attribute value documentation and null otherwise.static org.eclipse.lsp4j.MarkupContentcreateMarkupContent(CMAttributeDeclaration cmAttribute, CMElementDeclaration ownerElement, ISharedSettingsRequest request) Returns a markup content for attribute name documentation and null otherwise.static org.eclipse.lsp4j.MarkupContentcreateMarkupContent(CMElementDeclaration cmElement, String textContent, ISharedSettingsRequest support) Returns a markup content for element text documentation and null otherwise.static org.eclipse.lsp4j.MarkupContentcreateMarkupContent(CMElementDeclaration cmElement, ISharedSettingsRequest support) Returns a markup content for element documentation and null otherwise.generate(Collection<CMAttributeDeclaration> attributes, String tagName) generate(Collection<CMAttributeDeclaration> attributes, String tagName, boolean filterRequired) Generates attribute text for the given attributes.generate(Collection<CMAttributeDeclaration> attributes, String tagName, boolean filterRequired, DOMElement element) generate(CMElementDeclaration elementDeclaration, String prefix, boolean generateEndTag) Returns the XML generated from the given element declaration.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 StringgenerateAttributeValue(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 StringgenerateDocumentation(String documentation, String schemaURI, boolean html) Returns a properly formatted documentation string with source.generateMissingElements(ContentModelManager contentModelManager, DOMElement element, boolean generateOnlyRequired) Returns the line delimiter.Returns the whitespaces indentation.voidsetNamespacePrefixes(String rootNamespace, Map<String, String> namespacePrefixes) Sets namespace prefix mappings for document generation.voidsetUseTypeDefaults(boolean useTypeDefaults)
-
Constructor Details
-
Method Details
-
setNamespacePrefixes
Sets namespace prefix mappings for document generation. When set, child elements whose namespace differs from the root namespace will be generated with the corresponding prefix.- Parameters:
rootNamespace- the root element's namespace (default namespace).namespacePrefixes- mapping from namespace URI to prefix.
-
setUseTypeDefaults
public void setUseTypeDefaults(boolean useTypeDefaults) -
generateMissingElements
public String generateMissingElements(ContentModelManager contentModelManager, DOMElement element, boolean generateOnlyRequired) -
getLineDelimiter
Returns the line delimiter.- Returns:
- the line delimiter.
-
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-generateOnlyChildren- true if only is children of the given element is to be generatedlevel- the level at which the first element will be generated atgenerateOnlyRequired- 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
-
generate
public String generate(Collection<CMAttributeDeclaration> attributes, String tagName, boolean filterRequired) Generates attribute text for the given attributes.- Parameters:
attributes- the attributes to generate.tagName- the tag name of the element.filterRequired- whentrue, only attributes whereCMAttributeDeclaration.isRequired()returnstrueare generated; whenfalse, all given attributes are generated.- Returns:
- the generated attribute text.
-
generate
public String generate(Collection<CMAttributeDeclaration> attributes, String tagName, boolean filterRequired, DOMElement element) -
generateDocumentation
Returns a properly formatted documentation string with source. If there is no content then null is returned.- Parameters:
documentation-schemaURI-- Returns:
-