By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,112 Members | 1,584 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,112 IT Pros & Developers. It's quick & easy.

2 Dare (xmlschema question)

P: n/a
Hello, All!

It seems the bug
(http://groups.google.com/groups?hl=r...3b01c28a00%242
08bc860%2439ef2ecf%40TKMSFTNGXA08&rnum=8&prev=/groups%3Fq%3DschemaLocation%2
BXmlSchema%2B.NET%26hl%3Dru%26lr%3D%26ie%3DUTF-8%26selm%3Da53b01c28a00%25242
08bc860%252439ef2ecf%2540TKMSFTNGXA08%26rnum%3D8) wasn't fixed neither in
v1.1 nor in v2.0.

Here is exception

Unhandled Exception: System.Xml.Schema.XmlSchemaException: Cannot resolve
schema Location attribute.
at Modile1.ValidationSchemaCallBack(Object sender, ValidationEventArgs e)
at System.Xml.Schema.BaseProcessor.SendValidationEven t(XmlSchemaException
e, XmlSeverityType severity)
at System.Xml.Schema.SchemaCollectionPreprocessor.Loa dExternals(XmlSchema
schema, XmlSchemaCollection xsc)
at System.Xml.Schema.SchemaCollectionPreprocessor.Exe cute(XmlSchema
schema, String targetNamespace, Boolean loadExternals, XmlSchemaCollection
xsc)
at System.Xml.Schema.XmlSchema.CompileSchema(XmlSchem aCollection xsc,
XmlResolver resolver, SchemaInfo schemaInfo, String ns,
ValidationEventHandler validationEventHandler, XmlNameTable nameTable,
Boolean CompileContentModel)
at System.Xml.Schema.XmlSchema.Compile(ValidationEven tHandler
validationEventHandler)

Moreover, new XmlSchemaSet class, i'm afraid, have the same bug. I must
explicitly add all included schemas via Add method to get it work.

What i want is automatic addition all included schemas into the schema set.

With best regards, Alex Shirshov.
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
The XmlSchemaSet does use the baseUri of the main schema to locate its
imports and includes.

The problem might be related to how you add your main schema to the
XmlSchemaSet. If you add the main schema by using the overload that takes in
XmlReader and you created the XmlTextReader by passing in a stream (and did
not pass in the baseUri of the file)
then, the baseUri of the main schema would be string.Empty.

Stream fileStream = File.OpenRead(url);
XmlTextReader reader = new XmlTextReader(fileStream);
XmlSchemaSet set = new XmlSchemaSet();
set.Add(null, reader);
Console.WriteLine(set.Count);

If the schema is loaded as shown above, the baseUri of the main schema is
string.Empty as XmlTextReader accepts baseUri only when the corresponding
overload is used.
XmlTextReader reader = new XmlTextReader(mySchemaUrl, fileStream);

or add the schema to the set passing in the url directly.

Thanks,
Priya

"Alex Shirshov" <no****@mail.ru> wrote in message
news:Oy******************@TK2MSFTNGP09.phx.gbl...
Hello, All!

It seems the bug
(http://groups.google.com/groups?hl=r...3b01c28a00%242 08bc860%2439ef2ecf%40TKMSFTNGXA08&rnum=8&prev=/groups%3Fq%3DschemaLocation%2 BXmlSchema%2B.NET%26hl%3Dru%26lr%3D%26ie%3DUTF-8%26selm%3Da53b01c28a00%25242 08bc860%252439ef2ecf%2540TKMSFTNGXA08%26rnum%3D8) wasn't fixed neither in
v1.1 nor in v2.0.

Here is exception

Unhandled Exception: System.Xml.Schema.XmlSchemaException: Cannot resolve
schema Location attribute.
at Modile1.ValidationSchemaCallBack(Object sender, ValidationEventArgs e) at System.Xml.Schema.BaseProcessor.SendValidationEven t(XmlSchemaException e, XmlSeverityType severity)
at System.Xml.Schema.SchemaCollectionPreprocessor.Loa dExternals(XmlSchema schema, XmlSchemaCollection xsc)
at System.Xml.Schema.SchemaCollectionPreprocessor.Exe cute(XmlSchema
schema, String targetNamespace, Boolean loadExternals, XmlSchemaCollection
xsc)
at System.Xml.Schema.XmlSchema.CompileSchema(XmlSchem aCollection xsc,
XmlResolver resolver, SchemaInfo schemaInfo, String ns,
ValidationEventHandler validationEventHandler, XmlNameTable nameTable,
Boolean CompileContentModel)
at System.Xml.Schema.XmlSchema.Compile(ValidationEven tHandler
validationEventHandler)

Moreover, new XmlSchemaSet class, i'm afraid, have the same bug. I must
explicitly add all included schemas via Add method to get it work.

What i want is automatic addition all included schemas into the schema set.
With best regards, Alex Shirshov.

Nov 12 '05 #2

P: n/a
Hello, Priya!
You wrote on Fri, 23 Jul 2004 15:29:25 -0700:

PLM> The problem might be related to how you add your main schema to the
PLM> XmlSchemaSet. If you add the main schema by using the overload that
PLM> takes in XmlReader and you created the XmlTextReader by passing in a
PLM> stream (and did not pass in the baseUri of the file)
PLM> then, the baseUri of the main schema would be string.Empty.
[Sorry, skipped]

I'm loading schema in another way:

Dim rd As New IO.StreamReader(pathToSchema)
Dim _schema as Schema.XmlSchema = Schema.XmlSchema.Read(rd, AddressOf
ValidationSchemaCallBack)
Dim ss as new Schema.XmlSchemaSet
ss.Add(_schema)

SourceURI of the schema is string.empty in this case.

PLM> If the schema is loaded as shown above, the baseUri of the main schema
PLM> is string.Empty as XmlTextReader accepts baseUri only when the
PLM> corresponding overload is used.
PLM> XmlTextReader reader = new XmlTextReader(mySchemaUrl, fileStream);

In other words, i have to load schema only via XmlTextReader! Great!

PLM> or add the schema to the set passing in the url directly.

What does xmlschema need for? I don't even compile it!

PLM> "Alex Shirshov" <no****@mail.ru> wrote in message
PLM> news:Oy******************@TK2MSFTNGP09.phx.gbl...
??>> Hello, All!
??>>
??>> It seems the bug
??>>
PLM> (http://groups.google.com/groups?hl=r...adm=a53b01c28a
PLM> 00%242
??>>
PLM> 08bc860%2439ef2ecf%40TKMSFTNGXA08&rnum=8&prev=/groups%3Fq%3DschemaLoca
PLM> tion%2
??>>
PLM> BXmlSchema%2B.NET%26hl%3Dru%26lr%3D%26ie%3DUTF-8%26selm%3Da53b01c28a00
PLM> %25242
??>> 08bc860%252439ef2ecf%2540TKMSFTNGXA08%26rnum%3D8) wasn't fixed neither
??>> in v1.1 nor in v2.0. Here is exception Unhandled Exception:
System.Xml.Schema.XmlSchemaException: Cannot
??>> resolve schema Location attribute. at
??>> Modile1.ValidationSchemaCallBack(Object sender, ValidationEventArgs
PLM> e)
??>> at
PLM> System.Xml.Schema.BaseProcessor.SendValidationEven t(XmlSchemaException
??>> e, XmlSeverityType severity)
??>> at
PLM> System.Xml.Schema.SchemaCollectionPreprocessor.Loa dExternals(XmlSchema
??>> schema, XmlSchemaCollection xsc)
??>> at System.Xml.Schema.SchemaCollectionPreprocessor.Exe cute(XmlSchema
??>> schema, String targetNamespace, Boolean loadExternals,
??>> XmlSchemaCollection xsc) at
??>> System.Xml.Schema.XmlSchema.CompileSchema(XmlSchem aCollection
??>> xsc, XmlResolver resolver, SchemaInfo schemaInfo, String
??>> ns, ValidationEventHandler validationEventHandler, XmlNameTable
??>> nameTable, Boolean CompileContentModel) at
??>> System.Xml.Schema.XmlSchema.Compile(ValidationEven tHandler validationE
??>> ventHandler) Moreover, new XmlSchemaSet class, i'm afraid, have the
??>> same bug. I must explicitly add all included schemas via Add method to
??>> get it work. What i want is automatic addition all included schemas
??>> into the schema
PLM> set.
??>>
??>> With best regards, Alex Shirshov.
??>>

With best regards, Alex Shirshov.
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.