diff --git a/README.md b/README.md index 48e8b317..447a3cf8 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ The following settings are supported: * [`xml.codeLens.enabled`](https://github.com/redhat-developer/vscode-xml/blob/master/docs/CodeLens.md): Enable/disable XML CodeLens. Default is `false`. * [`xml.preferences.showSchemaDocumentationType`](https://github.com/redhat-developer/vscode-xml/blob/master/docs/Preferences.md#documentation-type): Specifies the source of the XML schema documentation displayed on hover and completion. Default is `all`. * [`xml.validation.enabled`](https://github.com/redhat-developer/vscode-xml/blob/master/docs/Validation.md): Enable/disable all validation. Default is `true`. + * [`xml.validation.namespaces.enabled`](https://github.com/redhat-developer/vscode-xml/blob/master/docs/Validation.md#xmlvalidationsnamespacesenabled): Enable/disable namespaces validation. Default is `always`. Ignored if [`xml.validation.enabled`](https://github.com/redhat-developer/vscode-xml/blob/master/docs/Validation.md) is set to `false`. * [`xml.validation.schema.enabled`](https://github.com/redhat-developer/vscode-xml/blob/master/docs/Validation.md#xmlvalidationschemaenabled): Enable/disable schema based validation. Default is `always`. Ignored if [`xml.validation.enabled`](https://github.com/redhat-developer/vscode-xml/blob/master/docs/Validation.md) is set to `false`. * [`xml.validation.disallowDocTypeDecl`](https://github.com/redhat-developer/vscode-xml/blob/master/docs/Validation.md#disallow-doc-type-declarations): Enable/disable if a fatal error is thrown if the incoming document contains a DOCTYPE declaration. Default is `false`. * [`xml.validation.resolveExternalEntities`](https://github.com/redhat-developer/vscode-xml/blob/master/docs/Validation.md#resolve-external-entities): Enable/disable resolve of external entities. Default is `false`. diff --git a/docs/Validation.md b/docs/Validation.md index a89eda97..9cefa35b 100644 --- a/docs/Validation.md +++ b/docs/Validation.md @@ -420,6 +420,36 @@ Demonstration of the different behaviour: ## xml.validation.schema.enabled +The `xml.validation.namespaces.enabled` gives the capability to enable / disable the namespaces (prefix) validation. It can be configured with 3 values: + + * `always`: enable schema based validation. + * `never`: disable schema based validation. + * `onNamespaceEncountered`: enable namespaces validation only when the root element declares an xmlns namespace. + +To understand the `onNamespaceEncountered` settings value, lets go through an example: + +Create the XML `foo.xml` file: + +```xml + + + +``` + +In `always` you will have error, in `onNamespaceEncountered` you will have none error. + +Declares a namespaces in the foo root element: + +```xml + + + +``` + +In `onNamespaceEncountered` you will see a prefix error. + +## xml.validation.schema.enabled + The `xml.validation.schema.enabled` gives the capability to enable / disable the validation based on XSD. It can be configured with 3 values: * `always`: enable schema based validation. diff --git a/package.json b/package.json index 3a0b4707..6c0411cb 100644 --- a/package.json +++ b/package.json @@ -307,6 +307,22 @@ "markdownDescription": "Enable/disable all validation. Default is `true`.", "scope": "window" }, + "xml.validation.namespaces.enabled": { + "type": "string", + "default": "always", + "enum": [ + "always", + "never", + "onNamespaceEncountered" + ], + "markdownEnumDescriptions": [ + "Enable namespaces validation.", + "Disable namespaces validation.", + "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" + }, "xml.validation.schema.enabled": { "type": "string", "default": "always",