I am editing an XML file in Visual Studio that references an XSD at a relative path with spaces in one of the folder names. Visual studio does not seem to be impressed.
If I remove the space names from the folder it works and I can navigate.
<?xml version="1.0" encoding="UTF-8"?>
<SyncTests xmlns="http://www.mimosa.org/ccom4" releaseID="1.0" versionID="4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mimosa.org/ccom4 ../../CCOM/BOD/Messages/OperationandCondition/synctests.xsd">
But the original folder name has spaces in "Operation and Condition".
<?xml version="1.0" encoding="UTF-8"?>
<SyncTests xmlns="http://www.mimosa.org/ccom4" releaseID="1.0" versionID="4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mimosa.org/ccom4 ../../CCOM/BOD/Messages/Operation and Condition/synctests.xsd">
I've been trying to get it to work with various incantations of file:///
and %20
for spaces but haven't been able to get it to work yet.
The folder structure is coming from another repo, and I'm hoping to be able to leave it as-is (with spaces).
The value of xsi:schemaLocation
is a sequence space-separated pairs of XML namespace values and XSD file locations. Since whitespace is used to delimit both these component pairs and the parts of each pair, clearly unescaped whitespace cannot also appear in the XSD file specification.
The solution is to use %20
instead of raw space characters within the file path to the XSD. You say you've tried this unsuccessfully in various combinations with other experiments. Backtrack to the case you proved to work when you eliminated the spaces in the directory path the XSD. Using that exact case, make only a single change: Substitute %20
where you wish there to be a space, and make the corresponding change to the path in filesystem (using actual, not escaped, spaces there – use no more or less than were used in the xsi:schemaLocation
value.
That should work. If it doesn't post a minimum, complete, verifiable example that proves that it does not, along with the XSD processor that you're using. Be sure to actually validate a document instance against the associated XSD to separate significant XML-XSD issues from insignificant Visual Studio IDE parsing limitations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With