C# 我可以在XmlSchemaSet.Add()方法的Uri参数中指定本地文件位置吗?
C# 我可以在XmlSchemaSet.Add()方法的Uri参数中指定本地文件位置吗?,c#,.net,xml,schema,C#,.net,Xml,Schema,XmlSchemaSet.Add()方法采用Uri和目标命名空间,但当我尝试传入本地文件位置时,它会产生错误 _schemaUri = @"L:\schemaDoc.xsd"; XmlSchemaSet schemas = new XmlSchemaSet(); schemas.Add(_schemaUri, _targetNamespace); 错误: NotSupportedException was caught The URI prefix is not recognized. 对
XmlSchemaSet.Add()
方法采用Uri
和目标命名空间,但当我尝试传入本地文件位置时,它会产生错误
_schemaUri = @"L:\schemaDoc.xsd";
XmlSchemaSet schemas = new XmlSchemaSet();
schemas.Add(_schemaUri, _targetNamespace);
错误:
NotSupportedException was caught
The URI prefix is not recognized.
对。您混淆了添加方法的参数。第一个参数是目标名称空间,第二个参数是URI。因此,您的代码应该如下所示:
_schemaUri = @"L:\schemaDoc.xsd";
XmlSchemaSet schemas = new XmlSchemaSet();
schemas.Add(_targetNamespace, _schemaUri);
有关更多详细信息,请参阅文档:
是的。您混淆了添加方法的参数。第一个参数是目标名称空间,第二个参数是URI。因此,您的代码应该如下所示:
_schemaUri = @"L:\schemaDoc.xsd";
XmlSchemaSet schemas = new XmlSchemaSet();
schemas.Add(_targetNamespace, _schemaUri);
有关更多详细信息,请参阅文档:
根据MSDN文档,schemaUri和targetNamespace参数的顺序与此相反 来自MSDN:
XmlSchemaSet.Add方法(字符串,字符串)
在指定给XmlSchemaSet的URL处添加XML架构定义语言(XSD)架构
Namespace: System.Xml.Schema
Assembly: System.Xml (in System.Xml.dll)
public XmlSchema Add(
string targetNamespace,
string schemaUri
)
参数
targetNamespace
Type: System.String
The schema targetNamespace property, or null to use the targetNamespace specified in the schema.
schemaUri
Type: System.String
The URL that specifies the schema to load.
根据MSDN文档,schemaUri和targetNamespace参数的顺序与此相反 来自MSDN:
XmlSchemaSet.Add方法(字符串,字符串)
在指定给XmlSchemaSet的URL处添加XML架构定义语言(XSD)架构
Namespace: System.Xml.Schema
Assembly: System.Xml (in System.Xml.dll)
public XmlSchema Add(
string targetNamespace,
string schemaUri
)
参数
targetNamespace
Type: System.String
The schema targetNamespace property, or null to use the targetNamespace specified in the schema.
schemaUri
Type: System.String
The URL that specifies the schema to load.