Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

What's new in the Visual Studio Code XML Extension

July 24, 2019
Nikolas Komonen
Related topics:
IDEsJava
Related products:
Developer Tools

Share:

    A new and improved version of the Visual Studio Code XML Extension by Red Hat has been released under version 0.8.0. This new release brings new features to provide even more support for XSD-related features (the blueprint file of an XML document) along with various performance improvements.

    New Features

    Jump to opposite tag:

    Sometimes in large documents, the opposite start/end tag can be located off the screen somewhere else, making it difficult to find. Now tags are treated as hyperlinks and, through Ctrl+click, you can now jump around from either the start or end tag to the opposite end.

    Jump to opposite tag

    CDATA and comment completion:

    You can now easily complete the confusing CDATA block, along with comments.

    CDATA and comment completion

     

    XSD-related updates

    Accurate XSD-based completion:

    Prior to this release when creating an element in either an XML or XSD document the auto-completion suggestions based on XSDs were not always correct. Depending on many constraints such as minOccurs/maxOccurs, if the elements were in a sequence … the provided completion item could be invalid. In version 0.8.0, we now provide only valid elements.

    See below where a sequence with 2 elements is declared but only the first one is provided for completion:

    XSD-related updates

    XML file validation on external XSD changes:

    Originally for XML validation relative to the XSD, validation would only be triggered on an XSD change if it was open/changed internally within the VS Code application. As of this release, the server will track that XSD file externally, detect all changes, and perform the appropriate actions.

    The image below shows a validation error on an XML file in VS Code after the XSD it is linked to was changed externally in vim.

    XML file validation on external XSD changes

    Highlight a specific type in an XSD file:

    In XSD files, you can reference a type, a type defines a specific XML structure that the XML document must follow. This type can be reused and applied to multiple areas in the document, which can lead to type occurrences being used all over the place. With the ability to highlight all references, users can scroll through the document and see all of these references without having to manually search for each use.

    Highlight a specific type in an XSD file

    Auto-complete types in an XSD file:

    After defining a type, you can start applying it to elements in the XSD file. Normally, you would have to know which types have already been defined and then type it making sure to write it correctly. This auto-complete feature now gathers all existing types and provides them through completion.

    Auto-complete types in an XSD file

    Jump to the definition of a type:

    If you are in an XSD working with an element that uses a type, you might want to go to the actual definition of it to be able to see its structure. You can now Ctrl+click and go directly to the definition without having to manually search for the definition through all the other implementations.

    Jump to the definition of a type

    Search the references of a type:

    By selecting Find All References, you can now find all uses of the schema type. Doing so in VS Code will open up a mid-sized window that groups together all references to that type, making it easy to find and read through every use of the type.

    Search the references of a type

    See the number of references of a type as a CodeLens:

    Similar to the Find All References, we also provide a CodeLens that is also clickable. This will bring up the same pop-up window from Find All References as well as show how many there are.

    See the number of references of a type as a CodeLens

    Jump to the definition of a type from the XML document:

    Similar to the previous ability to go to the type definition from an XSD file, you can also right-click and select Go to Type Definition to find the type that the XML implementation references. Before you would have to figure out which element is being referenced in the XSD and then find the type definition of that element definition.

    Jump to the definition of a type from the XML document

    Documentation improvements

    Documentation from hover and completion is provided as Markdown:

    In an XSD element, documentation can be written to provide some information on that element. XML allows for the use of Markdown or HTML, and when rendering HTML it did not display well with the LSP:

    Documentation improvements information on that element

    With this release, the following documentation will now be properly displayed in Markdown, resulting in:

    Documentation will now be properly displayed in markdown

    Additionally, at the bottom of the description hyperlinks to the connected XSD file are provided:

    Hyperlinks to the connected XSD file are provided

    Performance improvements

    This release had a focus on performance improvements, and we did just that by both decreasing memory usage and improving server speed.

    Speed improvements:

    To get a bit more technical, one improvement to speed was replacing the use of some regular expressions (regex) with hand-crafted java code. In this case, the regex checked for attribute names, but as you can imagine multiple attribute name regex calls during parsing could become a bit taxing. After this change, we noticed a 2-3x speed improvement on large files!

    Document symbols preferences:

    Performance improvements

    The Language Server Protocol provides a feature known as Document Symbols/Outline. On the left side of the above gif, is the Outline, which has a symbol for each significant piece in the XML document. In a large document, you will have a huge list of these symbols that will most likely be unhelpful because of the sheer amount of them. Whenever something changes in the document, these symbols have to be recalculated, which, as you can imagine for a large document, would be very penalizing.

    To account for this, we’ve provided the ability to either selectively disable the Outline for files matched by a pattern or to just disable it completely. Doing so took a huge load off of the CPU and allowed for improved performance with large files.

    Memory improvements:

    Under the hood of the language server, we found some inefficiencies that were causing large hits to the memory; here was one of them.

    Normally when a user types, a new copy of the entire document is sent to the server to be processed. As the file grows in size it is easy to see the problem with this method as a user ends up typing multiple characters continuously. Incremental Syncing is a method provided by the LSP that allows only the changed characters to be sent to the server to provide the same result with much less data being transferred. So, that’s what we did. In doing so, a large amount of memory was saved since the buffer to hold this data would only have to be enough to hold a few characters at most instead of the entire document.

    Last updated: November 8, 2023

    Recent Posts

    • Introducing Red Hat build of Cryostat 4.0

    • How we improved AI inference on macOS Podman containers

    • How OpenShift Virtualization supports VM live migration

    • How SELinux deny rules improve system security

    • Advanced time manipulation with GDB

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    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

    Red Hat legal and privacy links

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

    Report a website issue