C# 및 .net 3.5를 사용하여 포함하는 스키마에 대해 XML 문서의 유효성을 검사하려고합니다. > xmldocument 및 중첩 스키마
을 another.xsd 포함 another.xsd - -스키마를 거기에 포함이
Schema1.xsd은 다음과 같습니다> 등 내가 Schema1을 추가하려고하면
base.xsd. xsd XmlDocument 다음 오류가 발생합니다.
'YesNoType'유형이 선언되지 않았거나 단순 유형이 아닙니다.
Schema1.xsd 스키마를로드 할 때 base.xsd 파일이 포함되어 있지 않기 때문에이 오류가 발생한다고 생각합니다.
XmlSchemaSet 클래스를 사용하려고하는데 XmlResolver URI를 스키마 위치로 설정합니다.
참고 : 모든 스키마가 같은 디렉토리 E에서 살고 : \ 데브 \ 홈페이지 \ XmlSchemas를
여기에 코드를입니다
string schemaPath = "E:\\Dev\\Main\\XmlSchemas";
XmlDocument xmlDocSchema = new XmlDocument();
XmlSchemaSet s = new XmlSchemaSet();
XmlUrlResolver resolver = new XmlUrlResolver();
Uri baseUri = new Uri(schemaPath);
resolver.ResolveUri(null, schemaPath);
s.XmlResolver = resolver;
s.Add(null, XmlReader.Create(new System.IO.StreamReader(schemaPath + "\\Schema1.xsd"), new XmlReaderSettings { ValidationType = ValidationType.Schema, XmlResolver = resolver }, new Uri(schemaPath).ToString()));
xmlDocSchema.Schemas.Add(s);
ValidationEventHandler valEventHandler = new ValidationEventHandler
(ValidateNinoDobEvent);
try
{
xmlDocSchema.LoadXml(xml);
xmlDocSchema.Validate(valEventHandler);
}
catch (XmlSchemaValidationException xmlValidationError)
{
// need to interogate the Validation Exception, for possible further
// processing.
string message = xmlValidationError.Message;
return false;
}
사람이에 대해 XmlDocument를 검증에 대한 올바른 방향으로 날 지점 수 중첩 된 포함 스키마. 내가 무엇을 당신이해야 할 것은 스키마를 병합하는 것입니다 생각
현재로서는 C# .NET과 같은 것이 없습니다. –