Reputation: 4493
XmlSchemaSet.Add()
method takes a Uri
and target namespace, but when I try to pass in a local file location it produces an error.
_schemaUri = @"L:\schemaDoc.xsd";
XmlSchemaSet schemas = new XmlSchemaSet();
schemas.Add(_schemaUri, _targetNamespace);
ERROR:
NotSupportedException was caught
The URI prefix is not recognized.
Upvotes: 2
Views: 3803
Reputation: 7067
According to the MSDN documentation, you have the schemaUri and targetNamespace parameters in the reverse order.
From MSDN:
XmlSchemaSet.Add Method (String, String)
Adds the XML Schema definition language (XSD) schema at the URL specified to the XmlSchemaSet.
Namespace: System.Xml.Schema
Assembly: System.Xml (in System.Xml.dll)
public XmlSchema Add(
string targetNamespace,
string schemaUri
)
Parameters
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.
http://msdn.microsoft.com/en-us/library/1hh8b082(v=vs.110).aspx
Upvotes: 1
Reputation: 1078
Yes. You have confused the parameters of the Add method. The first parameter is the target namespace, with the second being the URI. So your code should look like this:
_schemaUri = @"L:\schemaDoc.xsd";
XmlSchemaSet schemas = new XmlSchemaSet();
schemas.Add(_targetNamespace, _schemaUri);
Refer to the documentation for more details:
http://msdn.microsoft.com/en-us/library/1hh8b082%28v=vs.110%29.aspx
Upvotes: 5