Home > Uncategorized > Solution for error “Cannot resolve the ‘schemaLocation’ attribute” message of XMLNotepad 2007

Solution for error “Cannot resolve the ‘schemaLocation’ attribute” message of XMLNotepad 2007

At a project I’m doing I have several XSD files (XML-Schema) where one includes an other with relative paths and some XML files that refer to one of the XSDs (which includes some other XSDs, which in turn include others etc.). Then when opening the .XML file in XMLNotepad2007 I was seeing the error message "Cannot resolve the ‘schemaLocation’ attribute" message of XMLNotepad 2007 and XSD types I was using weren’t resolved
 
The reason was that I was using say:
 
<DATA xsi:noNamespaceSchemaLocation="../schemas/Emergency.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
in my XML
 
and was using
 
<xs:include schemaLocation="General.xsd" />
 
in my XSDs since all .XSD files were in the "schemas" folder and all XML files in my ASP.net application’s "App_Data" folder
 
All XSD files were parsed ok in XMLSpy 2007 (it can integrate with VS.net2005) and with VS.NET’s XML Schema editor and also when editing the XML file. However in XMLNotepad they didn’t work OK
 
The reason seems to be that in VS.net2005 the relative paths in all included XSD files are resolved relative to the XSD file, but in XMLNotepad 2007 they seem to be resolved relative to the XML file. This might be a bug (will report to MS) with the path "resolver" class implementation in XMLNotepad 2007, but you can easily workarround it in my case. Just use "../schemas/General.xsd" instead of "General.xsd". It’s the same, but will resolve OK when resolved from both the "schemas" (where XSD files are) and the "App_Data" subfolders (were the XML files are).
 
The above "workarround" does help XMLNotepad file the child schemas when you right-click one and select "Goto Definition", but it seems it didn’t really solve the problem. The problem was eventually solved by using View/Options… menu of XMLNotepad2007 and adding all my schema files (.xsd) there. BTW, I use one schema that imports the rest, so adding just it works fine too
 
THERE DEFINITELY IS THOUGH A BUG IN XMLNotepad 2007, where if you drag-drop an XML file onto a shortcut to its .EXE file, or to its EXE file, or drag-drop the XML file onto an already opened XMLNotepad window, then it shows the above message and can’t resolve types included in schemas that the main schema imports. Using its File/Open menu option to open the file opens it up ok.
Advertisements
Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: