473,387 Members | 1,304 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Cannot resolve the schemaLocation attribute C#

Hi,
I am using an xml schema (Schema1.xsd) which refers to two other
Schemas as follows.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:plcm-s="http://www.mycompany.com/plcm"
targetNamespace="http://www.mycompany.com/plcm"
elementFormDefault="qualified" attributeFormDefault="unqualified">

<xsd:include schemaLocation="Schema2.xsd"/>
<xsd:include schemaLocation="Schema3.xsd"/>

All three schemas are stored in a Database as strings (SQL Server
2000).
Now I am trying to load the Schema1 from datbase by using the following
code.

public XmlSchema GetSchema()
{
XmlSchema PLCMSchema = null;
String schema1StringFromDatabase=//Get Schema1 from
Database
String schema2StringFromDatabase=//Get Schema2 from
Database
String schema3StringFromDatabase=//Get Schema3 from
Database
try
{
TextReader schemaTextReader = new
StringReader(schema1StringFromDatabase) as TextReader;
XmlTextReader schemaXmlReader = new
XmlTextReader(schemaTextReader);
XmlSchema schemaPLCM = XmlSchema.Read(schemaXmlReader,
new ValidationEventHandler(schemaSet_ValidationEventHa ndler));

XmlSchemaSet schemaset = new XmlSchemaSet();
schemaset.ValidationEventHandler += new
ValidationEventHandler(schemaSet_ValidationEventHa ndler);
schemaset.Add(schemaPLCM);
schemaset.Compile();
foreach (XmlSchema schema in schemaset.Schemas())
{
PLCMSchema = schema;
}
}
catch (Exception exception)
{

System.Windows.Forms.MessageBox.Show("Error in
PLCMWorkbenchShared.GetSchema()" + System.Environment.NewLine +
exception.Message);
}
return PLCMSchema;
}

But the SchemaSet_ValidationEventHandler Returns the error "Cannot
resolve the schemaLocation attribute".

Is there any way I can load the Schema1 from Database without errors
(the other two schemas are also in database)?

Any help is greatly appreciated.

Thanks,
Ramesh

May 30 '06 #1
1 11237
Since schema2 and schema3 are resources in the database, the schema set's
default XmlResolver (XmlUrlResolver) will not know how to get them.
You can do one of two things:
1. Set XmlResolver property on XmlSchemaSet to null and add schema1 to set.
Then manually traverse the Includes of schema1 and set schema2 and schema3
objects as includes. Then call compile()
2. You can use a custom resolver that returns back the schema objects from
the database when the schema set requests the schemas for location
schema2.xsd and schema3.xsd

For a sample on how to do option 2, see
http://blogs.msdn.com/mfussell/archi...03/237416.aspx

Thanks,
Priya

"techie" <ra***********@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hi,
I am using an xml schema (Schema1.xsd) which refers to two other
Schemas as follows.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:plcm-s="http://www.mycompany.com/plcm"
targetNamespace="http://www.mycompany.com/plcm"
elementFormDefault="qualified" attributeFormDefault="unqualified">

<xsd:include schemaLocation="Schema2.xsd"/>
<xsd:include schemaLocation="Schema3.xsd"/>

All three schemas are stored in a Database as strings (SQL Server
2000).
Now I am trying to load the Schema1 from datbase by using the following
code.

public XmlSchema GetSchema()
{
XmlSchema PLCMSchema = null;
String schema1StringFromDatabase=//Get Schema1 from
Database
String schema2StringFromDatabase=//Get Schema2 from
Database
String schema3StringFromDatabase=//Get Schema3 from
Database
try
{
TextReader schemaTextReader = new
StringReader(schema1StringFromDatabase) as TextReader;
XmlTextReader schemaXmlReader = new
XmlTextReader(schemaTextReader);
XmlSchema schemaPLCM = XmlSchema.Read(schemaXmlReader,
new ValidationEventHandler(schemaSet_ValidationEventHa ndler));

XmlSchemaSet schemaset = new XmlSchemaSet();
schemaset.ValidationEventHandler += new
ValidationEventHandler(schemaSet_ValidationEventHa ndler);
schemaset.Add(schemaPLCM);
schemaset.Compile();
foreach (XmlSchema schema in schemaset.Schemas())
{
PLCMSchema = schema;
}
}
catch (Exception exception)
{

System.Windows.Forms.MessageBox.Show("Error in
PLCMWorkbenchShared.GetSchema()" + System.Environment.NewLine +
exception.Message);
}
return PLCMSchema;
}

But the SchemaSet_ValidationEventHandler Returns the error "Cannot
resolve the schemaLocation attribute".

Is there any way I can load the Schema1 from Database without errors
(the other two schemas are also in database)?

Any help is greatly appreciated.

Thanks,
Ramesh

May 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John | last post by:
I have an input document that contains a large base64 encoded document. This document also declares a schema location in the root element. I want to write an XSL stylesheet that makes an exact...
0
by: Sarah Tegtmeier | last post by:
Hi I have a question about the correct use of the attribute xsi:schemaLocation. My programm has to process XML files where the value of this attribute causes some problems. The programm is...
3
by: Thomas Fischer | last post by:
Hi, i have a very complex XSD with frequently use of xsd:extension, xsd:restriction and xsd:redefine. Now i would like to process a XSL transformation based on the *resulted* Schema. But I don't...
0
by: Ron James | last post by:
I'm developing a GUI application in C#. I have a schema file (.XSD) and am able to serialize and deserialize the applications data using the schema file to an .XML file. (I'm using xsd.exe to...
2
by: Pet Matrix. | last post by:
Hi, I am trying to validate an XML file using the XmlValidatingReader and XmlUrlResolver. The code for which goes like this: // Read the XML file. XmlTextReader xmlReader = new XmlTextReader(...
2
by: kaush | last post by:
Hi all, I am trying to serialize a C# object into a XML document using "XmlSerializer" class. One of the elements of the XML document needs a "xsi:schemaLocation" attribute. I am not sure how to...
2
by: grochmal | last post by:
I am trying to use XmlSerializer to serialize a class I have created specifically for generating an XML file. The problem is that the XML file must contain a xsi:schemaLocation attribute in my...
3
by: Lord0 | last post by:
I am trying to implement variable content containers using an abstract type and type substitution. My schema is as follows: <?xml version="1.0" encoding="UTF-8"?> <schema...
5
by: carlpayne1984 | last post by:
Hi all, I'm fairly new to XML, however already I have studied myself stupid without being able to solve this problem. Basically, I have an XML file/Schema about a CD catalog that I've created that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.