0

I am trying to validate my XML against an existing XSD file in Visual Studio Code and have tried a few of the suggested validation processes in Redhat XML, but struggling to get any of the validation results to appear.

A colleague managed to get the validation to work with xsi:SchemaLocation but something is not working for me. (specific file paths and addresses changed)

Header in XML:

<COSD:COSD
  xmlns="http://www.address.uk/location/location"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.address.uk/location/location file:///c%3a/Users/Username/Documents/Temp/filename.xsd">
  <MAINXML/>
</COSD:COSD>

XSD header I haven't updated from the predefined schema, but it comes as per the below:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:COSD="http://www.address.uk/location/location" 
  version="9-0-1" #
  id="AnonymisedName" 
  xmlns="http://www.address.uk/location/location" 
  targetNamespace="http://www.address.uk/location/location" 
  finalDefault="extension">
  <MAINBODY>
</xs:schema>

The xmlns and targetNamespace matches the xlmns in the XML header.

I must be missing something in order to bind the XML and XSD together to get the validation, but any thoughts/troubleshooting ideas would be greatly appreciated.

Tried other methods from https://github.com/redhat-developer/vscode-xml/blob/main/docs/Validation.md.

The one attempted above using xsi:SchemaLocation has been made to work elsewhere but not in my instance, hence using this method.

Expecting to see schema validation issues in VS Code Problems section.

TRlionel
  • 11
  • 2
  • Please can you edit your question and format the XML code correctly. – kimbert May 24 '23 at 11:30
  • Apologies, updated the code and thanks @GSerg for the edit. I have tried the validation included in the other question (to the best of my ability) by no change. still shows in the problem section "No problems have been detected in the workspace" and we have ensured there are problems to detect! – TRlionel May 24 '23 at 11:53
  • Does this answer your question? [Validate XML with VS Code](https://stackoverflow.com/q/46198147/11683) – GSerg May 24 '23 at 18:48
  • Solution Found: The issue was relating to the Code Workspace that Visual Studio Code was assigned to. The workspace was assigned to Jupyter Workbook so this needed to be removed via the File --> Open Workspace from File. Check that the Visual Studio Code header does not specify a Code Workspace that is not xml compatable – TRlionel May 25 '23 at 10:06

1 Answers1

1

Solution Found: The issue was relating to the Code Workspace that Visual Studio Code was assigned to. The workspace was assigned to Jupyter Workbook so this needed to be removed via the File --> Open Workspace from File. Check that the Visual Studio Code header does not specify a Code Workspace that is not xml compatible, then the xsi:SchemaLocation binding method will work.

TRlionel
  • 11
  • 2