我有一个.xsd文件,我用它来使用Visual Studio中的xsd.exe工具生成代码.一些类成员是Guids,xsd.exe工具提供2个警告:
命名空间" http://microsoft.com/wsdl/types/ "无法在此架构中引用.未声明类型" http://microsoft.com/wsdl/types/:guid ".
Guid类型被识别,因为生成的C#文件有效且有效.谁知道如何摆脱这些警告?
验证XSD和生成为System.Guid的类成员的正确语法是什么?
erb*_*rbi 42
谢谢大家,我发现了如何删除警告.
正如sysrqb所说,wsdl命名空间已被删除或从未存在过.似乎xsd.exe工具在内部知道Guid定义,但它无法验证xsd架构.
正如boj指出的那样,使用Guids验证模式的唯一方法是(重新)在模式中定义该类型.这里的技巧是将Guid类型添加到相同的" http://microsoft.com/wsdl/types "命名空间.这样,xsd.exe将在http://microsoft.com/wsdl/types:Guid和System.Guid 之间建立正确的关联.
我为guid类型创建了一个新的xsd文件:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://microsoft.com/wsdl/types/" >
<xs:simpleType name="guid">
<xs:annotation>
<xs:documentation xml:lang="en">
The representation of a GUID, generally the id of an element.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="\{[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\}"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
然后,我用我原来的xsd文件和这个新的xsd文件运行xsd.exe:
xsd.exe myschema.xsd guid.xsd /c
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29351 次 |
| 最近记录: |