Skip to content

Instantly share code, notes, and snippets.

@jpoehls
Last active August 29, 2015 14:27
Show Gist options
  • Save jpoehls/8ebd991ab340ffeb6f29 to your computer and use it in GitHub Desktop.
Save jpoehls/8ebd991ab340ffeb6f29 to your computer and use it in GitHub Desktop.
XmlSchemaInference bug
The type attribute cannot be present with either simpleType or complexType.
at System.Xml.Schema.XmlSchemaSet.InternalValidationCallback(Object sender, ValidationEventArgs e)
at System.Xml.Schema.BaseProcessor.SendValidationEvent(XmlSchemaException e, XmlSeverityType severity)
at System.Xml.Schema.Preprocessor.PreprocessElementContent(XmlSchemaElement element)
at System.Xml.Schema.Preprocessor.PreprocessLocalElement(XmlSchemaElement element)
at System.Xml.Schema.Preprocessor.PreprocessParticle(XmlSchemaParticle particle)
at System.Xml.Schema.Preprocessor.PreprocessComplexType(XmlSchemaComplexType complexType, Boolean local)
at System.Xml.Schema.Preprocessor.PreprocessElementContent(XmlSchemaElement element)
at System.Xml.Schema.Preprocessor.PreprocessLocalElement(XmlSchemaElement element)
at System.Xml.Schema.Preprocessor.PreprocessParticle(XmlSchemaParticle particle)
at System.Xml.Schema.Preprocessor.PreprocessComplexType(XmlSchemaComplexType complexType, Boolean local)
at System.Xml.Schema.Preprocessor.PreprocessElementContent(XmlSchemaElement element)
at System.Xml.Schema.Preprocessor.PreprocessElement(XmlSchemaElement element)
at System.Xml.Schema.Preprocessor.Preprocess(XmlSchema schema, String targetNamespace, ArrayList imports)
at System.Xml.Schema.Preprocessor.Execute(XmlSchema schema, String targetNamespace, Boolean loadExternals)
at System.Xml.Schema.XmlSchemaSet.PreprocessSchema(XmlSchema& schema, String targetNamespace)
at System.Xml.Schema.XmlSchemaSet.Reprocess(XmlSchema schema)
at System.Xml.Schema.XmlSchemaInference.InferSchema1(XmlReader instanceDocument, XmlSchemaSet schemas)
at System.Xml.Schema.XmlSchemaInference.InferSchema(XmlReader instanceDocument, XmlSchemaSet schemas)
at UserQuery.Main()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
// https://connect.microsoft.com/VisualStudio/feedback/details/1691659
void Main()
{
var inference = new XmlSchemaInference();
var schemaSet = new XmlSchemaSet();
using (var reader = new XmlTextReader(new StringReader(@"
<doc>
<table>
<cols />
</table>
</doc>
")))
{
inference.InferSchema(reader, schemaSet);
}
using (var reader = new XmlTextReader(new StringReader(@"
<doc>
<table>
<cols>text</cols>
</table>
<table>
<cols total=""true"">text</cols>
</table>
</doc>
")))
{
inference.InferSchema(reader, schemaSet); // crashes here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment