Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an XML schema extension for Visual Studio Code?

I would like to write an XML Schema in Visual Studio Code and then some XML that is valid against that schema but surprisingly there does not seem to be a facility to do this either built-in or via an extension. Similar questions have been asked in the past (here and here) but I wanted to renew this question and also ask if no-one is aware of an existing extension, is this something one can request of the vscode github team themselves and if so, how?

like image 779
Dan Maharry Avatar asked Dec 15 '17 10:12

Dan Maharry


People also ask

Does Visual Studio Code support XML?

Description. This VS Code extension provides support for creating and editing XML documents, based on the LemMinX XML Language Server.

How do I view the XML schema in Visual Studio?

To access the XML Schema Explorer, do one of the following: If you are on the Start View, click the XML Schema Explorer link. If you are on the Graph View or the Content Model View and have nodes in your workspace, use the context (right-click) menu to select the XML Schema Explorer.

Does Visual Studio have an XML editor?

The XML editor in Visual Studio is based on the text editor and includes additional support for the XML languages. When you open an XML file in Visual Studio, it opens in the XML editor. The XML editor includes the following features: XML 1.0 syntax checking.


3 Answers

The XML extension, by Red Hat, is now available in the Marketplace. It supports, among other things, XSD and DTD validation, autocompletion from XSD, documentation on hover, tag autoclose, formatting...

It's based on LemMinX, a Java-based language server.

As of vscode-xml 0.15.0, Java is no longer required to run it (a native binary will be downloaded on install).

like image 73
Fred Bricon Avatar answered Sep 21 '22 21:09

Fred Bricon


I just found Xml Complete by rogalmic that doesn't need Java to be installed.

Features:

  • Basic linter (XML + partial XSD validation)
  • Fast autocomplete based on XSD (utilizes comments from XSD)
  • Formatting XML (selected range or full document)
  • Auto-closing and auto-rename for currently edited tag (works only for single tag in given line)

All you need to do is to specify the xsd in the root of your xml.

Here's an example:

<?xml version="1.0"?> <Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:schemaLocation="MyPathToMyXsd/MySchema.xsd"> <!-- Xml content --> </Root> 
like image 40
Élodie Avatar answered Sep 19 '22 21:09

Élodie


You can install XML Language Support extension which support Structural XML validation and XML Schema Definition (XSD) validation, by launching VS Code and then Quick Open (Ctrl+P), paste the following command

ext install IBM.XMLLanguageSupport

, and press enter. After installation press Reload button to activate . You may need to install Language Support for Java(TM) if you have not before by using the following command in VS Code extensions

ext install redhat.java

like image 33
Noha Salah Avatar answered Sep 21 '22 21:09

Noha Salah