2

is there any easy and generic way to locate a schema based on namespace?. for example, in the XML below, how do i find the schema for http://schemas.microsoft.com/developer/msbuild/2003 ?

<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
kjhughes
  • 106,133
  • 27
  • 181
  • 240
yigal
  • 3,923
  • 8
  • 37
  • 59

2 Answers2

5

Where to look for an XSD given an XML namespace:

  1. Check the location given by any available xsi:schemaLocation hint: xsi:schemaLocation="namespace location".

    In this case, we do not have a schema location hint.

  2. Check the namespace value if in URI form by typing it into a browser.

    In this case, the http://schemas.microsoft.com/developer/msbuild/2003 namespace is in the form of a URI, but there is no XSD at the endpoint:

    The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

  3. Check the URI Resolution entries of any XML Catalogs that are in play.

    In this case, no XML catalogs were mentioned.

  4. Check the XML Standards Library.

    In this case, there's no entry for the sought namespace.

  5. Check Wikipedia's List of XML markup languages and List of XML schemas.

    In this case, there's no entry for the sought namespace.

  6. Check the schema association mechanism of your XML tool. Here are a few:

    In this case, no tool was mentioned, but it is a Microsoft namespace, so if Visual Studio is installed, check the associations listed in the XML Schemas Dialog Box and the local schema cache.

    According to this source, the XSD for the given namespace is msbuild.xsd and can be located in the Visual Studio schema cache. It is the schema for MSBuild make files.

Bottom line: In general, the above procedure should allow you to resolve a namespace to a physical location for an XSD, but beware that the difficulty can vary from simple to impossible.

kjhughes
  • 106,133
  • 27
  • 181
  • 240
1

There's no mapping between XML namespaces and resource URLs where you can expect to find the schema resources. Namespaces are just that - spaces in which names can be defined so as not to conflict with others.

BadZen
  • 4,083
  • 2
  • 25
  • 48
  • 1
    In addition, namespaces happen to generally be URLs (uniform resource locators) which causes confusion because you'd think because they're URLs something is behind them. For common W3C schemas, you can actually get the schema or at least some documentation by dereferencing the URL. But namespace identifiers don't have to be URLs, and may be URN/URIs. Tl;dr for most schemas, this string doesn't really mean much. – FrobberOfBits Sep 16 '14 at 01:49
  • 1
    It's not harmful, it's just convention - albeit somewhat misleading. http://stackoverflow.com/questions/5758041/why-are-urls-in-xml-namespaces – FrobberOfBits Sep 16 '14 at 02:18