在更一般的意义上,我想更好地了解编译的确切效果。遗憾的是,MSDN文档在这个主题上有点不清楚(至少,据我所能找到的,也许我错过了一个澄清一切的页面)。
在更直接的意义上,我关心的是:当通过加载到XmlSchemaSet中的XmlSchemaSet进行解析时,我需要手动解析使用ref属性的任何潜在元素,还是可以期望编译方法已经解决了这些问题,并将complexType中的适当全局元素(或在complexType中的组中,适当的序列、选择等)替换到XmlSchemaElement或XmlSchemaType的属性中?
发布于 2016-05-04 21:46:14
看来答案是肯定的,在XmlSchemaSet源代码中浏览了一下之后。下面是编译器代码的相关片段(除非我严重误解了,它似乎复制了引用元素的Type和声明):
if (!xe.RefName.IsEmpty) {
XmlSchemaElement e = (XmlSchemaElement)elements[xe.RefName];
if (e == null) {
throw new XmlSchemaException(Res.Sch_UndeclaredElement, xe.RefName.ToString(), xe);
}
CompileElement(e);
if (e.ElementDecl == null) {
throw new XmlSchemaException(Res.Sch_RefInvalidElement, xe.RefName.ToString(), xe);
}
xe.SetElementType(e.ElementSchemaType);
decl = e.ElementDecl.Clone();
}
else { ...https://stackoverflow.com/questions/37032621
复制相似问题