diff --git a/docs/Validation.md b/docs/Validation.md index 88146dd7..f381950a 100644 --- a/docs/Validation.md +++ b/docs/Validation.md @@ -450,6 +450,54 @@ See [RelaxNG features](Features/RelaxNGFeatures.md#relaxng-features) # Other Validation Settings +## Per-folder and per-language validation settings + +The following `xml.validation.*` settings have `language-overridable` scope, which means they can be overridden per workspace folder (in multi-root workspaces) and per language ID: + + * `xml.validation.enabled` + * `xml.validation.namespaces.enabled` + * `xml.validation.schema.enabled` + * `xml.validation.disallowDocTypeDecl` + * `xml.validation.resolveExternalEntities` + * `xml.validation.xInclude.enabled` + * `xml.validation.noGrammar` + +### Per-folder overrides (multi-root workspace) + +In a [multi-root workspace](https://code.visualstudio.com/docs/editor/multi-root-workspaces), each folder can have its own `.vscode/settings.json` with different validation settings: + +**Folder A** `.vscode/settings.json`: +```json +{ + "xml.validation.enabled": true, + "xml.validation.schema.enabled": "always" +} +``` + +**Folder B** `.vscode/settings.json`: +```json +{ + "xml.validation.enabled": false +} +``` + +When validating an XML file, the XML language server pulls the settings scoped to that file's workspace folder. + +### Per-language overrides + +If you have a custom language ID registered as an XML language participant (see [Extensions - Custom language](Extensions.md#custom-language)), you can override validation settings per language: + +```json +{ + "xml.validation.noGrammar": "hint", + "[myxml]": { + "xml.validation.noGrammar": "ignore" + } +} +``` + +XML files report a hint for documents without a grammar, while files with language ID `myxml` silently ignore it. + ## Disallow Doc Type Declarations If `xml.validation.disallowDocTypeDeclaration` is set to `true` (default is `false`), all Doc Type Declarations (DTD) will be marked as errors. The DOCTYPE is marked as an error regardless if the doctype is an internally declared or a reference to an external DTD. Standalone `.dtd` files are not marked as an error. diff --git a/package.json b/package.json index 0d7629b9..4c689370 100644 --- a/package.json +++ b/package.json @@ -766,7 +766,7 @@ "type": "boolean", "default": true, "markdownDescription": "Enable/disable all validation. Default is `true`.", - "scope": "window" + "scope": "language-overridable" }, "xml.validation.namespaces.enabled": { "type": "string", @@ -782,7 +782,7 @@ "Enable namespaces validation only when the root element declares an xmlns namespace." ], "markdownDescription": "Enable/disable namespaces validation. Default is `always`. Ignored if `#xml.validation.enabled#` is set to `false`. See [here](command:xml.open.docs?%5B%7B%22page%22%3A%22Validation%22%2C%22section%22%3A%22xmlnamespaceschemaenabled%22%7D%5D) for more information.", - "scope": "window" + "scope": "language-overridable" }, "xml.validation.schema.enabled": { "type": "string", @@ -798,25 +798,25 @@ "Enable schema based validation only when the declared xsi:schemaLocation hint or xsi:noNamespaceSchemaLocation is valid for the root element." ], "markdownDescription": "Enable/disable schema based validation. Default is `always`. Ignored if `#xml.validation.enabled#` is set to `false`. See [here](command:xml.open.docs?%5B%7B%22page%22%3A%22Validation%22%2C%22section%22%3A%22xmlvalidationschemaenabled%22%7D%5D) for more information.", - "scope": "window" + "scope": "language-overridable" }, "xml.validation.disallowDocTypeDecl": { "type": "boolean", "default": false, "markdownDescription": "Enable/disable if a fatal error is thrown if the incoming document contains a DOCTYPE declaration. Default is `false`. See [here](command:xml.open.docs?%5B%7B%22page%22%3A%22Validation%22%2C%22section%22%3A%22disallow-doc-type-declarations%22%7D%5D) for more information", - "scope": "window" + "scope": "language-overridable" }, "xml.validation.resolveExternalEntities": { "type": "boolean", "default": false, "markdownDescription": "Enable/disable resolve of external entities. Default is `false`. See [here](command:xml.open.docs?%5B%7B%22page%22%3A%22Validation%22%2C%22section%22%3A%22resolve-external-entities%22%7D%5D) for more information. Disabled for untrusted workspaces", - "scope": "window" + "scope": "language-overridable" }, "xml.validation.xInclude.enabled": { "type": "boolean", "default": false, "markdownDescription": "Enable/disable validation for `xi:include`. Default is `false`. See [here](command:xml.open.docs?%5B%7B%22page%22%3A%22Validation%22%2C%22section%22%3A%22xmlvalidationxincludeenabled%22%7D%5D) for more information.", - "scope": "window" + "scope": "language-overridable" }, "xml.validation.noGrammar": { "type": "string", @@ -829,7 +829,7 @@ ], "default": "hint", "markdownDescription": "The message severity when a document has no associated grammar. Default is `hint`.", - "scope": "window" + "scope": "language-overridable" }, "xml.symbols.enabled": { "type": "boolean",