Skip to content

Commit

Permalink
Manage namespaces / prefix validation with a settings
Browse files Browse the repository at this point in the history
  • Loading branch information
angelozerr committed Jan 15, 2021
1 parent d73238c commit 6c777f3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
30 changes: 30 additions & 0 deletions docs/Validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<foo>
<prefix:bar />
</foo>
```

In `always` you will have error, in `onNamespaceEncountered` you will have none error.

Declares a namespaces in the foo root element:

```xml
<foo xmlns="http:foo" >
<prefix:bar />
</foo>
```

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.
Expand Down
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 6c777f3

Please sign in to comment.