是否有适用于 VS Code 的 XML 架构扩展
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47830544/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there an XML Schema extension for VS Code
提问by Dan Maharry
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 (hereand 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?
我想在 Visual Studio Code 中编写一个 XML 架构,然后编写一些对该架构有效的 XML,但令人惊讶的是,似乎没有内置或通过扩展来执行此操作的工具。过去曾问过类似的问题(这里和这里),但我想更新这个问题,并询问是否没有人知道现有的扩展,这是可以向 vscode github 团队自己提出的要求,如果是这样,如何?
采纳答案by Fred Bricon
The XMLextension, 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...
由 Red Hat 开发的XML扩展现在可在 Marketplace 中使用。它支持 XSD 和 DTD 验证、XSD 自动完成、悬停文档、标签自动关闭、格式设置等。
It's also based on a language server running with Java: LSP4XML
它还基于运行 Java 的语言服务器:LSP4XML
回答by élodie
I just found Xml Completeby rogalmic that doesn't need Java to be installed.
我刚刚发现rogalmic 的Xml Complete不需要安装 Java。
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)
- 基本 linter(XML + 部分 XSD 验证)
- 基于 XSD 的快速自动完成(利用来自 XSD 的注释)
- 格式化 XML(选定范围或完整文档)
- 当前编辑标签的自动关闭和自动重命名(仅适用于给定行中的单个标签)
All you need to do is to specify the xsd in the root of your xml.
您需要做的就是在 xml 的根目录中指定 xsd。
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>
回答by Noha Salah
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
您可以安装支持结构 XML 验证和 XML 架构定义 (XSD) 验证的 XML 语言支持扩展,方法是启动 VS Code,然后快速打开 (Ctrl+P),粘贴以下命令
ext install IBM.XMLLanguageSupport
ext 安装 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
,然后按 Enter。安装后按重新加载按钮激活。如果您之前没有在 VS Code 扩展中使用以下命令,您可能需要安装 Language Support for Java(TM)
ext install redhat.java
分机安装redhat.java
回答by pe3k
回答by Matt Bierner
Not built-in, but there are a few extensions in the marketplace:
不是内置的,但市场上有一些扩展:

