Skip to content

XML validation errors in Salesforce projects #6364

@tzinm

Description

@tzinm

Summary

I’ve encountered a recurring issue in my Salesforce project when using VSCode. All *-meta.xml files are flagged with errors in the Problems panel.

The error shown is exactly the same as described in this previously closed issue: All XML files produce 'cvc-elt.1.a: Cannot find the declaration of element' in VSCode · Issue #3552

Steps To Reproduce:

The issue seems to originate from the vscode-xml extension which uses the Lemminx XML Language Server to provide XML support via the Language Server Protocol.

Expected result

No XML validation errors.

Actual result

XML validation errors like: cvc-elt.1.a: Cannot find the declaration of element 'CustomApplication'.

Show fixes suggest: Replace 'CustomApplication' with 'LightningComponentBundle'.

Possible Workarounds

While none of the following are perfect solutions, they at least suppress the validation errors, making it easier to focus on actual issues.

  1. Disable validation for *-meta.xml files via xml.validation.filters

You can configure this in your settings.json (It is necessary to take into account the settings precedence):

"xml.validation.filters": [
  {
    "pattern": "**-meta.xml",
    "enabled": false
  }
]

This disables validation for any file ending in -meta.xml.

References: https://github.com/redhat-developer/vscode-xml/blob/main/docs/Validation.md#xmlvalidationfilters

  1. Set xml.validation.schema.enabled to "onValidSchema"

This limits schema-based validation to cases where a valid xsi:schemaLocation or xsi:noNamespaceSchemaLocation is found.

References: https://github.com/redhat-developer/vscode-xml/blob/main/docs/Validation.md#xmlvalidationschemaenabled

  1. Modify xmlns to use HTTPS
    Some suggest changing the namespace URI in xmlns from http to https. However, this is not reliable: SFDX rewrites the namespace on retrieve, which will undo this change.

Additional information

Salesforce Extension Version in VS Code: 64.1.0

Salesforce CLI Version: @salesforce/cli/2.92.7 wsl-x64 node-v22.15.0

OS and version: Debian 12 in WSL 2.4.13.0

VS Code version: version 1.101

Most recent version of the extensions where this was working: -

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions