如何按命名空间定位 XML 架构 (XSD)? [英] How to locate an XML Schema (XSD) by namespace?

查看:45
本文介绍了如何按命名空间定位 XML 架构 (XSD)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有简单通用的方法来定位基于命名空间的模式?例如,在下面的 XML 中,我如何找到 http://schemas.microsoft 的架构.com/developer/msbuild/2003 ?

解决方案

在给定 XML 命名空间的情况下,在哪里查找 XSD:

  1. 检查任何可用的给出的位置xsi:schemaLocation 提示:xsi:schemaLocation="命名空间位置".

    在这种情况下,我们没有架构位置提示.

  2. 通过在浏览器中键入名称来检查名称空间值是否为 URI 形式.

    在这种情况下,http://schemas.microsoft.com/developer/msbuild/2003 命名空间采用 URI 的形式,但端点处没有 XSD:<块引用>

    您正在寻找的资源已被删除,有它的名字已更改,或暂时不可用.

  3. 检查URI 解析任何XML目录<的条目/a> 正在播放.

    在这种情况下,没有提到 XML 目录.

  4. 查看 XML 标准库.

    在这种情况下,所寻求的命名空间没有条目.

  5. 检查维基百科的XML 标记语言列表XML 模式列表.

    在这种情况下,所寻求的命名空间没有条目.

  6. 检查您的 XML 工具的架构关联机制.以下是一些:

    在这种情况下,没有提到任何工具,但它是一个 Microsoft 命名空间,因此如果安装了 Visual Studio,请检查 XML 架构对话框和本地架构缓存中列出的关联.

    根据此来源,给定命名空间的 XSD 是msbuild.xsd 并且可以位于 Visual Studio 架构缓存中.它是 MSBuild 生成文件的架构.

底线: 一般来说,上述过程应该允许您将命名空间解析为 XSD 的物理位置,但请注意,难度可能从简单到不可能.

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">

解决方案

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.

这篇关于如何按命名空间定位 XML 架构 (XSD)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆