无法在本地引用 sqltypes 架构 xsd

Unable to locally reference sqltypes schema xsd

我正在使用从 T-sql 生成的 xml 文件模拟一些数据访问,例如:

SELECT * FROM dbo.my_table FOR XML AUTO, XMLSCHEMA 

这会生成一个工作文件,因为 schemaLocation 的 xsd 是在线托管的:

  <xsd:schema targetNamespace="mydata" xmlns:schema="mydata" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sqltypes="http://schemas.microsoft.com/sqlserver/2004/sqltypes" elementFormDefault="qualified">
    <xsd:import namespace="http://schemas.microsoft.com/sqlserver/2004/sqltypes" schemaLocation="http://schemas.microsoft.com/sqlserver/2004/sqltypes/sqltypes.xsd" />
    <xsd:element name="dbo.my_table">
      <xsd:complexType>
        <xsd:attribute name="Id" type="sqltypes:int" use="required" />
        <xsd:attribute name="Foo" type="sqltypes:int" use="required" />
        ...etc, etc.

我在测试时不能依赖互联网连接 运行 所以我想将它存储在本地。所以我下载 xsd 并将其与我的数据放在与 xml 相同的文件夹中,并像这样引用它:

schemaLocation="http://schemas.microsoft.com/sqlserver/2004/sqltypes sqltypes.xsd"

Cannot resolve the schemaLocation attribute

当然,除了有效的方法外,我已经尝试了各种方法的组合来引用它。

正确的语法是什么?

当前目录的定义在某些环境中可能会变得模糊。

尝试使用绝对路径:

schemaLocation="http://schemas.microsoft.com/sqlserver/2004/sqltypes 
                file:///c:/path/to/sqltypes.xsd"

如果这不起作用,请按照 Stack Overflow 问题的答案中的说明通过浏览器检查您的路径规范:How to reference a local XML Schema file correctly?