Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Improved schema binding and more in Red Hat XML extension for VS Code 0.12.0 and LemMinX

July 2, 2020
David Thompson
Related topics:
Developer toolsIDEsJava
Related products:
Developer Toolset

    The latest update of the Red Hat XML extension for Visual Studio Code (VS Code), version 0.12.0, is packed with bug fixes and new features. It includes the new version of the underlying Eclipse LemMinX XML language server. In this update, we streamlined the process of writing XML Schema Definitions (XSD) and Document Type Definitions (DTD). We also added shortcuts to bind XML documents to either of these types of XML grammar.

    This article demonstrates the highlights of the 0.12.0 update to XML extension for VS Code, including new formatting options to reduce visual clutter, support for <?xml-model … ?>, and context-aware snippets to assist with binding a document to an XML schema. For the full list of more than 50 enhancements and bug fixes, see the XML extension for VS Code changelog. You can also watch a video demonstration of the new features here:

    Note: Both the XML extension for VS Code, version 0.12.0, and the underlying LemMinX XML language server are now available in the Visual Studio Code Marketplace.

    Entity validation and completion

    Red Hat's XML extension for VS Code now supports entity validation and entity-name completion with hover-over and go-to definitions for locally and externally declared entities.

    Hovering over an entity displays the value that it represents and a link to the file where it was defined. Going to the entity definition brings the cursor to the line in the file where the entity was declared, whether that’s in the same file or an external file. If an entity is referenced but hasn’t yet been declared, you can use the new quick fix to define it in the doctype declaration. All of these options are demonstrated in Figure 1.

    A demo of the new new entity validation, completion, hover, and go-to definitions.
    Figure 1: The new entity validation and completion features with hover-over and go-to definitions.

    XSD documentation settings

    Prior to this release, hovering over an XSD element displayed all of the xs:documentation and xs:appinfo available for that element on a single line, along with a link to the XSD schema file. With this release, we introduced a new setting to help remove some of that visual clutter, as shown in Figure 2.

    The VSCode settings menu, displaying the different options available for displaying XSD documentation
    Here are the options available for displaying XSD element documentation
    Figure 2: New options for displaying the XSD element documentation.

    You can now use the xml.preferences.showSchemaDocumentationType setting to specify what you would like to see when you hover over an element: xs:documentation, xs:appinfo, both of these elements, or nothing at all. Also, as shown in Figure 3, subtitles now separate the xs:documentation and xs:appinfo elements when they are both present, making definitions easier to read.

    Before and after for hovering over an element with documentation. The hover now seperates appinfo and documentation using subtitles
    Hovering over which has xs:documentation and xs:appinfo in its XSD schema declaration while xml.preferences.showSchemaDocumentationType is set to all
    Figure 3: The hover feature now uses subtitles to separate app info and documentation.

    Formatting (xml.format)

    We introduced several new settings to the XML extension's formatting feature.

    Enforce quote style: Ignore or preferred

    The xml.format.enforceQuoteStyle setting indicates that the formatter should replace all quotations with the preferred quotation type (which is set in xml.preferences.quoteStyle) or ignore the preferred quotation type and leave the quotes as they are (which is the default setting). The demonstration in Figure 4 shows the new quote-style options.

    A demonstration of the formatter ignoring the preferred format style when enforceQuoteStyle is set to be ignored.
    Figure 4: The default Enforce Quote Style setting is to ignore the quote style.
    Figure 4: The default Enforce Quote Style setting is to ignore the quote style.

    Empty elements: Ignore, collapse, or expand

    The xml.format.emptyElements setting tells the formatter whether to write empty elements using an opening and closing tag (<img></img>), or using the shorthand notation (<img />). As a default setting, you can choose to preserve the format that is already in use. The demo in Figure 5 shows these options.

    Demo of the formatter expanding self-closing elements and turning self closing elements into an open and close tag, depending on the emptyElements setting.
    Figure 5: The formatter can expand or turn off self-closing elements depending on the Empty Elements setting.

    Preserve attribute line breaks: True or false

    If you enable the xml.format.preserveAttributeLineBreaks setting, the formatter will preserve line breaks before and after attributes. By default, the formatter places each attribute on a single line, so this setting is useful for indicating that attributes should stay on their respective lines. The demo in Figure 6 shows the formatter placing line breaks before and after attributes.

    A demonstration of the formatter preserving line breaks between attributes.
    Figure 6: The formatter can preserve line breaks before and after attributes.
    Figure 6: The formatter can preserve line breaks before and after attributes.

    Document links

    Navigating between XML documents and their schemas is easier in the new XML extension for VS Code. The extension now provides document links in the schemaLocation attribute for the xs:include and xs:import schema elements, as well as another document link in the href attribute for the xml-model processing instruction. Figure 7 shows an xs:schema with xs:include and xs:import elements.

    An xs schema with xs include and xs import, showing the underlined document links

    New XML model support

    The XML extension for VS Code now supports the <?xml-model … ?> method of binding an XML document to its schema. The XML document will be validated against the schema, providing all the same features that are already supported through existing methods of schema binding. We added a document link that links the href attribute of the <?xml-model … ?> instruction to the referenced schema document. As discussed in the next section, we also added snippets to help with writing the XML model schema references.

    Figure 8 shows a demonstration of an XML document being bound to an .xsd document through the <?xml-model … ?> processing instruction.

    A demonstration of an XML document being bound to an xs document through the xml-model processing instruction.
    Figure 8: An XML document is bound to an <code>.xsd</code> document through the <code>&lt;?xml-model … ?&gt;</code> processing instruction.

    Snippets

    We made several changes to improve snippets. Previously, snippets were a part of the XML extension for VS Code. With this update, we moved them to the server-side of the extension (LemMinX) using the JSON format. Not only does this change allow us to provide snippets to all of the Language Server Protocol (LSP) clients (such as Eclipse with Wild Web Developer, Emacs, and so on) but snippets are context-aware. For example, we can provide XML declaration snippets only if the document does not already have an XML declaration, and only if your cursor is on the first line of the document. We also added new snippets, such as for doctype declarations. The overall goal of adding these snippets is to make it easier to bind documents to schemas.

    Snippet demos

    The demo in Figure 9 shows some of the possible snippet completions.

    An empty file showing many possible snippet completions
    Here are several examples of the snippets now available in the new VS Code XML extension update
    Figure 9: Examples of snippets now available in the new XML extension for Visual Studio Code.

    In Figure 10, we use snippets to quickly create an XML document bound to .xsd schemas through schemaLocation and noNamespaceSchemaLocation. We then use a snippet to write an XML document with a doctype declaration.

    A demo that shows snippets that automatically generate schema bindings in blank XML files.

    In Figure 11, we use a snippet to quickly generate a doctype declaration that declares the root element of the XML document.

    A demo of using a snippet to generate a doctype declaration for an existing XML file.
    Figure 11: Using snippets to generate a doctype declaration.

    In a future release, we hope to provide snippets and quick fixes that generate schemas from existing XML documents.

    A new outline limit for symbols

    For performance reasons, we set a default limit of 6,000 symbol-tree items for the Outline view, which is located within the XML extension's Explorer. You can use the use xml.symbols.maxItemsComputed setting to manually configure the limit.

    When the symbol limit is reached for a particular file, a notification will appear, providing the current limit and a Configure Limit button, which navigates to the xml.symbols.maxItemsComputed setting in the VS Code settings UI. Figure 12 shows the error and the new button.

    VSCode displays an error message when the document symbol limit is exceeded
    A large file, file.xml has been opened. Since file.xml contains more than 6000 elements, the symbols tree has been capped at 6000 items.
    Figure 12: A large file with the symbols tree capped at 6,000 items.

    Conclusion

    Our goal with the 0.12.0 version of Red Hat's XML extension for Visual Studio Code was to improve the workflow of writing XML schemas and binding XML documents to a grammar. For the next release, we aim to improve the schema-writing workflow by providing quick fixes and snippets that make it easier to generate the schema for a particular XML document. If you encounter unexpected behavior in this release, feel free to open a GitHub issue.

    Note: Special thanks to Balduin Landolt, who contributed the <?xml-model … ?> snippets, as well as a fix that disables snippets if the cursor is before the XML prolog.

    Further information

    • Get the vscode-xml extension on the Visual Studio Marketplace.
    • Get the vscode-xml extension on GitHub.
    • Check out LemMinX, the XML Language Server on GitHub.
    • Open a new issue on the LemMinX GitHub page.
    • View the changelog for LemMinX.
    • Learn more about LemMinX being migrated to the Eclipse Foundation.
    Last updated: February 5, 2024

    Recent Posts

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.