Embedded schema failing
-
Wednesday, February 06, 2013 9:11 PM
Hi all;
Please look at the file www.windward.net/temp/EmbeddedSchema.xml which has an embedded schema. When we feed it to
XmlReaderSettings settings = new XmlReaderSettings {ProhibitDtd = false}; settings.ValidationType = ValidationType.Schema; settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ReportValidationWarnings | XmlSchemaValidationFlags.AllowXmlAttributes; using (XmlReader reader = XmlFileOpen.XmlReaderCreate(xmlUrl, settings, ConnectMode, credentials.FullName, credentials.Password)) { while (reader.Read()) // nada ; }We get:
System.Xml.Schema.XmlSchemaValidationException occurred Message=An element or attribute information item has already been validated from the '' namespace. It is an error if 'xsi:schemaLocation', 'xsi:noNamespaceSchemaLocation', or an inline schema occurs for that namespace. Source=System.Xml LineNumber=460 LinePosition=5 SourceUri=file:///C:/test/Report.xml StackTrace: at System.Xml.Schema.XmlSchemaValidator.SendValidationEvent(XmlSchemaValidationException e, XmlSeverityType severity) at System.Xml.Schema.XmlSchemaValidator.SendValidationEvent(String code, String msg, XmlSeverityType severity) at System.Xml.Schema.XmlSchemaValidator.AddSchema(XmlSchema schema) at System.Xml.XsdValidatingReader.ProcessInlineSchema() at System.Xml.XsdValidatingReader.Read() at WindwardArrow.net.windward.arrow.datasource.xml.XmlDataSourceInfo.CanConnect() in C:\src\jenova\11.1\Merge\WindwardArrow\net\windward\arrow\datasource\xml\XmlDataSourceInfo.cs:line 515 InnerException:I've read up a bunch on embedded schemas but while I found lots of examples, I can't find anything that lays out what is allowed and all ways this can be done. I'm assuming that the namespace needs to be specified in the root node but I tried that and it didn't work.
Any suggestions?
thanks - dave
Who will win The Windward International Collegiate Programming Championships?
All Replies
-
Friday, February 08, 2013 6:47 AM
One way to resolve this is set some namespace.
Verified with following code.
class Program
{
static void Main(string[] args)
{
string file = "EmbeddedSchema.xml";
XmlReaderSettings settings = new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore };
settings.ValidationType = ValidationType.Schema;
settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema |
XmlSchemaValidationFlags.ReportValidationWarnings |
XmlSchemaValidationFlags.AllowXmlAttributes;
using (XmlReader reader = XmlReader.Create(file, settings))
{
while (reader.Read() && reader.Name != "FirmID_Primary")
{
Console.WriteLine(reader.Name);
}
}
}
}And here's the start of the XML file, notice added http://sample.com/xml namespace.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <NewDataSet xmlns="http://sample.com/xml"> <xs:schema id="NewDataSet" xmlns="http://sample.com/xml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="Job"> <xs:complexType> <xs:sequence>
- Marked As Answer by DavidThi808 Friday, February 08, 2013 5:16 PM
-
Friday, February 08, 2013 5:18 PM
Thank you.
ps - is xmlns="" legal? Seems logical that an empty string counts as a url. But it feels wrong.
Who will win The Windward International Collegiate Programming Championships?

