Skip to content

Commit 6c777f3

Browse files
committed
Manage namespaces / prefix validation with a settings
See eclipse-lemminx/lemminx#960 Signed-off-by: azerr <azerr@redhat.com>
1 parent d73238c commit 6c777f3

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ The following settings are supported:
8484
* [`xml.codeLens.enabled`](https://github.com/redhat-developer/vscode-xml/blob/master/docs/CodeLens.md): Enable/disable XML CodeLens. Default is `false`.
8585
* [`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`.
8686
* [`xml.validation.enabled`](https://github.com/redhat-developer/vscode-xml/blob/master/docs/Validation.md): Enable/disable all validation. Default is `true`.
87+
* [`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`.
8788
* [`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`.
8889
* [`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`.
8990
* [`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`.

docs/Validation.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,36 @@ Demonstration of the different behaviour:
420420

421421
## xml.validation.schema.enabled
422422

423+
The `xml.validation.namespaces.enabled` gives the capability to enable / disable the namespaces (prefix) validation. It can be configured with 3 values:
424+
425+
* `always`: enable schema based validation.
426+
* `never`: disable schema based validation.
427+
* `onNamespaceEncountered`: enable namespaces validation only when the root element declares an xmlns namespace.
428+
429+
To understand the `onNamespaceEncountered` settings value, lets go through an example:
430+
431+
Create the XML `foo.xml` file:
432+
433+
```xml
434+
<foo>
435+
<prefix:bar />
436+
</foo>
437+
```
438+
439+
In `always` you will have error, in `onNamespaceEncountered` you will have none error.
440+
441+
Declares a namespaces in the foo root element:
442+
443+
```xml
444+
<foo xmlns="http:foo" >
445+
<prefix:bar />
446+
</foo>
447+
```
448+
449+
In `onNamespaceEncountered` you will see a prefix error.
450+
451+
## xml.validation.schema.enabled
452+
423453
The `xml.validation.schema.enabled` gives the capability to enable / disable the validation based on XSD. It can be configured with 3 values:
424454

425455
* `always`: enable schema based validation.

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,22 @@
307307
"markdownDescription": "Enable/disable all validation. Default is `true`.",
308308
"scope": "window"
309309
},
310+
"xml.validation.namespaces.enabled": {
311+
"type": "string",
312+
"default": "always",
313+
"enum": [
314+
"always",
315+
"never",
316+
"onNamespaceEncountered"
317+
],
318+
"markdownEnumDescriptions": [
319+
"Enable namespaces validation.",
320+
"Disable namespaces validation.",
321+
"Enable namespaces validation only when the root element declares an xmlns namespace."
322+
],
323+
"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.",
324+
"scope": "window"
325+
},
310326
"xml.validation.schema.enabled": {
311327
"type": "string",
312328
"default": "always",

0 commit comments

Comments
 (0)