473,698 Members | 2,339 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.c om/plcm"
targetNamespace ="http://www.mycompany.c om/plcm"
elementFormDefa ult="qualified" attributeFormDe fault="unqualif ied">

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

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 schema1StringFr omDatabase=//Get Schema1 from
Database
String schema2StringFr omDatabase=//Get Schema2 from
Database
String schema3StringFr omDatabase=//Get Schema3 from
Database
try
{
TextReader schemaTextReade r = new
StringReader(sc hema1StringFrom Database) as TextReader;
XmlTextReader schemaXmlReader = new
XmlTextReader(s chemaTextReader );
XmlSchema schemaPLCM = XmlSchema.Read( schemaXmlReader ,
new ValidationEvent Handler(schemaS et_ValidationEv entHandler));

XmlSchemaSet schemaset = new XmlSchemaSet();
schemaset.Valid ationEventHandl er += new
ValidationEvent Handler(schemaS et_ValidationEv entHandler);
schemaset.Add(s chemaPLCM);
schemaset.Compi le();
foreach (XmlSchema schema in schemaset.Schem as())
{
PLCMSchema = schema;
}
}
catch (Exception exception)
{

System.Windows. Forms.MessageBo x.Show("Error in
PLCMWorkbenchSh ared.GetSchema( )" + System.Environm ent.NewLine +
exception.Messa ge);
}
return PLCMSchema;
}

But the SchemaSet_Valid ationEventHandl er 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 11281
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.goo glegroups.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.c om/plcm"
targetNamespace ="http://www.mycompany.c om/plcm"
elementFormDefa ult="qualified" attributeFormDe fault="unqualif ied">

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

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 schema1StringFr omDatabase=//Get Schema1 from
Database
String schema2StringFr omDatabase=//Get Schema2 from
Database
String schema3StringFr omDatabase=//Get Schema3 from
Database
try
{
TextReader schemaTextReade r = new
StringReader(sc hema1StringFrom Database) as TextReader;
XmlTextReader schemaXmlReader = new
XmlTextReader(s chemaTextReader );
XmlSchema schemaPLCM = XmlSchema.Read( schemaXmlReader ,
new ValidationEvent Handler(schemaS et_ValidationEv entHandler));

XmlSchemaSet schemaset = new XmlSchemaSet();
schemaset.Valid ationEventHandl er += new
ValidationEvent Handler(schemaS et_ValidationEv entHandler);
schemaset.Add(s chemaPLCM);
schemaset.Compi le();
foreach (XmlSchema schema in schemaset.Schem as())
{
PLCMSchema = schema;
}
}
catch (Exception exception)
{

System.Windows. Forms.MessageBo x.Show("Error in
PLCMWorkbenchSh ared.GetSchema( )" + System.Environm ent.NewLine +
exception.Messa ge);
}
return PLCMSchema;
}

But the SchemaSet_Valid ationEventHandl er 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
2965
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 copy (including the namespace and schema location) of the input document except that it removes the base64 encoding and replaces it with the text 'REMOVED'. I have a stylesheet that does just that except that it drops the schemaLocation...
0
10737
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 written in C++ using Xerces C++ version 2.3.0. An older older version of the programm used Xerces C++ version 1.6.0. The XML files look like the following example:
3
1295
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 know, how I get the resulted schema. Example: ========
0
2677
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 generate my serializable class, XmlSerializer to Serialize and DeSerialize and XMLValidatingReader to validate. My intention is that application users can edit the content of the .XML file using their favorite XML editor as well as by using my...
2
1024
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( _PathToXMLDoc); XmlValidatingReader valReader = new XmlValidatingReader(xmlReader); valReader.ValidationType = ValidationType.Schema;
2
7496
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 add this to the XML element Please help me with if you can. Thanks, kaush
2
18461
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 root node but I can't figure out any way to do it. Here is what the resulting XML file must look like (small sample): <TXLife xmlns="http://ACORD.org/Standards/Life/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...
3
3473
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 xmlns="http://www.w3.org/2001/XMLSchema" xmlns:this="this" targetNamespace="this" elementFormDefault="qualified"> <complexType name="abstractAnswerType" abstract="true"/> <complexType name="yesWithDescType">
5
40926
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 I want to combine with an XML/Schema that a friend has created. Both XML files/Schema validate individually. Now comes the tricky part, combining them. I've created a new XML file and schema, called catalog.xml and catalog.xsd. Into the...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9027
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8895
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.