472,958 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Issues when validating xml in VS2003

I am trying to validate an xml file and schema and when I
am trying to validate I am getting the following error. I
have been trying to come out with a solution but I have
failed so far. The document validates ok in xmlSpy but it
fails in VS2003. Is there any article or fix for this?

Thnaks in advance.

Error:
======
"The Keyref 'Details' cannot find referred key or unique
in scope. An error occurred at file:///C:/test1.xml, (7,
4)..\n"
XML file:
<?xml version="1.0" encoding="UTF-8"?>
<Renewals>
<Renewal>
<Headers>
<e1>String</e1>
</Headers>
<Details>
<e1>String</e1>
<e2>0</e2>
</Details>
</Renewal>
</Renewals>

XSD file:
=========
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 rel. 4 U
(http://www.xmlspy.com) by Tomas Rivas (Tyco Healthcare-
Kendall) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="Renewals">
<xs:annotation>
<xs:documentation>Renewal
document</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element
name="Renewal">
<xs:complexType>

<xs:sequence>

<xs:element ref="Headers"/>

<xs:element ref="Details"/>

</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Headers">
<xs:complexType>
<xs:sequence>
<xs:element name="e1"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:key name="key1">
<xs:selector
xpath=".//Renewals/Renewal/Headers"/>
<xs:field xpath="e1"/>
</xs:key>
</xs:element>
<xs:element name="Details">
<xs:complexType>
<xs:sequence>
<xs:element name="e1"
type="xs:string"/>
<xs:element name="e2"
type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:keyref name="fKey" refer="key1">
<xs:selector
xpath=".//Renewals/Renewal/Details"/>
<xs:field xpath="e1"/>
</xs:keyref>
</xs:element>
</xs:schema>

=====================================
The code I am using is the following:
=====================================

public string ValidateXml(string inXMLLocation, string
inXSDLocation)
{
string errorsList = string.Empty;
try
{
// Read the xml file, and send this to
validator.
XmlTextReader xmlReader = new
XmlTextReader(inXMLLocation);

// load the schema file into an
XmlTextReader object
XmlTextReader xsdReader = new
XmlTextReader(inXSDLocation);
XmlSchemaCollection sc = new
XmlSchemaCollection();

// add the ValidationEventHandler to the
schema collection
sc.ValidationEventHandler += new
ValidationEventHandler(ValidationCallBack);
// add the schema to the
XmlSchemaCollection object
sc.Add("", xsdReader);
// create an XmlValidatingReader object
based on the Xml document
XmlValidatingReader rdr = new
XmlValidatingReader(xmlReader);

// set the ValidationType to a schema
rdr.ValidationType =
ValidationType.Schema;
rdr.Schemas.Add(sc);

rdr.ValidationEventHandler += new
ValidationEventHandler(ValidationCallBack);

while (rdr.Read());

errorsList = validationErrors;

//closing the readers and releasing the
handlers to the IFS docs.
//These readers were locking the files
when saving them to the IFS.
xmlReader.Close();
xsdReader.Close();
}
catch(Exception exc)
{
throw new Exception(string.Format("An
exception has occurred when executing method {0}.", (new
StackFrame()).GetMethod().Name), exc);
}
finally
{}
return errorsList;
}

Nov 12 '05 #1
4 1850
XmlValidatingReader expects the keyref to be defined within the scope of the
key that it refers to. Ie, the element on which the keyref is defined should
be the same as or a descendant of the element on which the key is defined.

If you move both the key and keyref definitions to the "Renewal" element as
shown below, it should work as expected.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Renewals">
<xs:annotation>
<xs:documentation>Renewal document</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="Renewal">
<xs:complexType>
<xs:sequence>
<xs:element ref="Headers"/>
<xs:element ref="Details"/>
</xs:sequence>
</xs:complexType>
<xs:key name="key1">
<xs:selector xpath="./Headers"/>
<xs:field xpath="e1"/>
</xs:key>
<xs:keyref name="fKey" refer="key1">
<xs:selector xpath="./Details"/>
<xs:field xpath="e1"/>
</xs:keyref>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="Headers">
<xs:complexType>
<xs:sequence>
<xs:element name="e1" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="Details">
<xs:complexType>
<xs:sequence>
<xs:element name="e1" type="xs:string"/>
<xs:element name="e2" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Thanks,
Priya

"Tomas Rivas" <to*********@tycohealthcare.com> wrote in message
news:2c****************************@phx.gbl...
I am trying to validate an xml file and schema and when I
am trying to validate I am getting the following error. I
have been trying to come out with a solution but I have
failed so far. The document validates ok in xmlSpy but it
fails in VS2003. Is there any article or fix for this?

Thnaks in advance.

Error:
======
"The Keyref 'Details' cannot find referred key or unique
in scope. An error occurred at file:///C:/test1.xml, (7,
4)..\n"
XML file:
<?xml version="1.0" encoding="UTF-8"?>
<Renewals>
<Renewal>
<Headers>
<e1>String</e1>
</Headers>
<Details>
<e1>String</e1>
<e2>0</e2>
</Details>
</Renewal>
</Renewals>

XSD file:
=========
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 rel. 4 U
(http://www.xmlspy.com) by Tomas Rivas (Tyco Healthcare-
Kendall) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="Renewals">
<xs:annotation>
<xs:documentation>Renewal
document</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element
name="Renewal">
<xs:complexType>

<xs:sequence>

<xs:element ref="Headers"/>

<xs:element ref="Details"/>

</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Headers">
<xs:complexType>
<xs:sequence>
<xs:element name="e1"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:key name="key1">
<xs:selector
xpath=".//Renewals/Renewal/Headers"/>
<xs:field xpath="e1"/>
</xs:key>
</xs:element>
<xs:element name="Details">
<xs:complexType>
<xs:sequence>
<xs:element name="e1"
type="xs:string"/>
<xs:element name="e2"
type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:keyref name="fKey" refer="key1">
<xs:selector
xpath=".//Renewals/Renewal/Details"/>
<xs:field xpath="e1"/>
</xs:keyref>
</xs:element>
</xs:schema>

=====================================
The code I am using is the following:
=====================================

public string ValidateXml(string inXMLLocation, string
inXSDLocation)
{
string errorsList = string.Empty;
try
{
// Read the xml file, and send this to
validator.
XmlTextReader xmlReader = new
XmlTextReader(inXMLLocation);

// load the schema file into an
XmlTextReader object
XmlTextReader xsdReader = new
XmlTextReader(inXSDLocation);
XmlSchemaCollection sc = new
XmlSchemaCollection();

// add the ValidationEventHandler to the
schema collection
sc.ValidationEventHandler += new
ValidationEventHandler(ValidationCallBack);
// add the schema to the
XmlSchemaCollection object
sc.Add("", xsdReader);
// create an XmlValidatingReader object
based on the Xml document
XmlValidatingReader rdr = new
XmlValidatingReader(xmlReader);

// set the ValidationType to a schema
rdr.ValidationType =
ValidationType.Schema;
rdr.Schemas.Add(sc);

rdr.ValidationEventHandler += new
ValidationEventHandler(ValidationCallBack);

while (rdr.Read());

errorsList = validationErrors;

//closing the readers and releasing the
handlers to the IFS docs.
//These readers were locking the files
when saving them to the IFS.
xmlReader.Close();
xsdReader.Close();
}
catch(Exception exc)
{
throw new Exception(string.Format("An
exception has occurred when executing method {0}.", (new
StackFrame()).GetMethod().Name), exc);
}
finally
{}
return errorsList;
}

Nov 12 '05 #2
XmlValidatingReader expects the keyref to be defined within the scope of the
key that it refers to. Ie, the element on which the keyref is defined should
be the same as or a descendant of the element on which the key is defined.

If you move both the key and keyref definitions to the "Renewal" element as
shown below, it should work as expected.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Renewals">
<xs:annotation>
<xs:documentation>Renewal document</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="Renewal">
<xs:complexType>
<xs:sequence>
<xs:element ref="Headers"/>
<xs:element ref="Details"/>
</xs:sequence>
</xs:complexType>
<xs:key name="key1">
<xs:selector xpath="./Headers"/>
<xs:field xpath="e1"/>
</xs:key>
<xs:keyref name="fKey" refer="key1">
<xs:selector xpath="./Details"/>
<xs:field xpath="e1"/>
</xs:keyref>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="Headers">
<xs:complexType>
<xs:sequence>
<xs:element name="e1" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="Details">
<xs:complexType>
<xs:sequence>
<xs:element name="e1" type="xs:string"/>
<xs:element name="e2" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Thanks,
Priya

"Tomas Rivas" <to*********@tycohealthcare.com> wrote in message
news:2c****************************@phx.gbl...
I am trying to validate an xml file and schema and when I
am trying to validate I am getting the following error. I
have been trying to come out with a solution but I have
failed so far. The document validates ok in xmlSpy but it
fails in VS2003. Is there any article or fix for this?

Thnaks in advance.

Error:
======
"The Keyref 'Details' cannot find referred key or unique
in scope. An error occurred at file:///C:/test1.xml, (7,
4)..\n"
XML file:
<?xml version="1.0" encoding="UTF-8"?>
<Renewals>
<Renewal>
<Headers>
<e1>String</e1>
</Headers>
<Details>
<e1>String</e1>
<e2>0</e2>
</Details>
</Renewal>
</Renewals>

XSD file:
=========
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 rel. 4 U
(http://www.xmlspy.com) by Tomas Rivas (Tyco Healthcare-
Kendall) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="Renewals">
<xs:annotation>
<xs:documentation>Renewal
document</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element
name="Renewal">
<xs:complexType>

<xs:sequence>

<xs:element ref="Headers"/>

<xs:element ref="Details"/>

</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Headers">
<xs:complexType>
<xs:sequence>
<xs:element name="e1"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:key name="key1">
<xs:selector
xpath=".//Renewals/Renewal/Headers"/>
<xs:field xpath="e1"/>
</xs:key>
</xs:element>
<xs:element name="Details">
<xs:complexType>
<xs:sequence>
<xs:element name="e1"
type="xs:string"/>
<xs:element name="e2"
type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:keyref name="fKey" refer="key1">
<xs:selector
xpath=".//Renewals/Renewal/Details"/>
<xs:field xpath="e1"/>
</xs:keyref>
</xs:element>
</xs:schema>

=====================================
The code I am using is the following:
=====================================

public string ValidateXml(string inXMLLocation, string
inXSDLocation)
{
string errorsList = string.Empty;
try
{
// Read the xml file, and send this to
validator.
XmlTextReader xmlReader = new
XmlTextReader(inXMLLocation);

// load the schema file into an
XmlTextReader object
XmlTextReader xsdReader = new
XmlTextReader(inXSDLocation);
XmlSchemaCollection sc = new
XmlSchemaCollection();

// add the ValidationEventHandler to the
schema collection
sc.ValidationEventHandler += new
ValidationEventHandler(ValidationCallBack);
// add the schema to the
XmlSchemaCollection object
sc.Add("", xsdReader);
// create an XmlValidatingReader object
based on the Xml document
XmlValidatingReader rdr = new
XmlValidatingReader(xmlReader);

// set the ValidationType to a schema
rdr.ValidationType =
ValidationType.Schema;
rdr.Schemas.Add(sc);

rdr.ValidationEventHandler += new
ValidationEventHandler(ValidationCallBack);

while (rdr.Read());

errorsList = validationErrors;

//closing the readers and releasing the
handlers to the IFS docs.
//These readers were locking the files
when saving them to the IFS.
xmlReader.Close();
xsdReader.Close();
}
catch(Exception exc)
{
throw new Exception(string.Format("An
exception has occurred when executing method {0}.", (new
StackFrame()).GetMethod().Name), exc);
}
finally
{}
return errorsList;
}

Nov 12 '05 #3
Thanks a lot. This worked perfectly.
-----Original Message-----
XmlValidatingReader expects the keyref to be defined within the scope of thekey that it refers to. Ie, the element on which the keyref is defined shouldbe the same as or a descendant of the element on which the key is defined.
If you move both the key and keyref definitions to the "Renewal" element asshown below, it should work as expected.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Renewals">
<xs:annotation>
<xs:documentation>Renewal document</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="Renewal">
<xs:complexType>
<xs:sequence>
<xs:element ref="Headers"/>
<xs:element ref="Details"/>
</xs:sequence>
</xs:complexType>
<xs:key name="key1">
<xs:selector xpath="./Headers"/>
<xs:field xpath="e1"/>
</xs:key>
<xs:keyref name="fKey" refer="key1">
<xs:selector xpath="./Details"/>
<xs:field xpath="e1"/>
</xs:keyref>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="Headers">
<xs:complexType>
<xs:sequence>
<xs:element name="e1" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="Details">
<xs:complexType>
<xs:sequence>
<xs:element name="e1" type="xs:string"/>
<xs:element name="e2" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Thanks,
Priya

"Tomas Rivas" <to*********@tycohealthcare.com> wrote in messagenews:2c****************************@phx.gbl...
I am trying to validate an xml file and schema and when I am trying to validate I am getting the following error. I have been trying to come out with a solution but I have
failed so far. The document validates ok in xmlSpy but it fails in VS2003. Is there any article or fix for this?

Thnaks in advance.

Error:
======
"The Keyref 'Details' cannot find referred key or unique in scope. An error occurred at file:///C:/test1.xml, (7, 4)..\n"
XML file:
<?xml version="1.0" encoding="UTF-8"?>
<Renewals>
<Renewal>
<Headers>
<e1>String</e1>
</Headers>
<Details>
<e1>String</e1>
<e2>0</e2>
</Details>
</Renewal>
</Renewals>

XSD file:
=========
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 rel. 4 U
(http://www.xmlspy.com) by Tomas Rivas (Tyco Healthcare- Kendall) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="Renewals">
<xs:annotation>
<xs:documentation>Renewal
document</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element
name="Renewal">
<xs:complexType>

<xs:sequence>

<xs:element ref="Headers"/>

<xs:element ref="Details"/>

</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Headers">
<xs:complexType>
<xs:sequence>
<xs:element name="e1"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:key name="key1">
<xs:selector
xpath=".//Renewals/Renewal/Headers"/>
<xs:field xpath="e1"/>
</xs:key>
</xs:element>
<xs:element name="Details">
<xs:complexType>
<xs:sequence>
<xs:element name="e1"
type="xs:string"/>
<xs:element name="e2"
type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:keyref name="fKey" refer="key1">
<xs:selector
xpath=".//Renewals/Renewal/Details"/>
<xs:field xpath="e1"/>
</xs:keyref>
</xs:element>
</xs:schema>

=====================================
The code I am using is the following:
=====================================

public string ValidateXml(string inXMLLocation, string
inXSDLocation)
{
string errorsList = string.Empty;
try
{
// Read the xml file, and send this to
validator.
XmlTextReader xmlReader = new
XmlTextReader(inXMLLocation);

// load the schema file into an
XmlTextReader object
XmlTextReader xsdReader = new
XmlTextReader(inXSDLocation);
XmlSchemaCollection sc = new
XmlSchemaCollection();

// add the ValidationEventHandler to the
schema collection
sc.ValidationEventHandler += new
ValidationEventHandler(ValidationCallBack);
// add the schema to the
XmlSchemaCollection object
sc.Add("", xsdReader);
// create an XmlValidatingReader object
based on the Xml document
XmlValidatingReader rdr = new
XmlValidatingReader(xmlReader);

// set the ValidationType to a schema
rdr.ValidationType =
ValidationType.Schema;
rdr.Schemas.Add(sc);

rdr.ValidationEventHandler += new
ValidationEventHandler(ValidationCallBack);

while (rdr.Read());

errorsList = validationErrors;

//closing the readers and releasing the
handlers to the IFS docs.
//These readers were locking the files
when saving them to the IFS.
xmlReader.Close();
xsdReader.Close();
}
catch(Exception exc)
{
throw new Exception(string.Format("An
exception has occurred when executing method {0}.", (new StackFrame()).GetMethod().Name), exc);
}
finally
{}
return errorsList;
}

.

Nov 12 '05 #4
Thanks a lot. This worked perfectly.
-----Original Message-----
XmlValidatingReader expects the keyref to be defined within the scope of thekey that it refers to. Ie, the element on which the keyref is defined shouldbe the same as or a descendant of the element on which the key is defined.
If you move both the key and keyref definitions to the "Renewal" element asshown below, it should work as expected.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Renewals">
<xs:annotation>
<xs:documentation>Renewal document</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="Renewal">
<xs:complexType>
<xs:sequence>
<xs:element ref="Headers"/>
<xs:element ref="Details"/>
</xs:sequence>
</xs:complexType>
<xs:key name="key1">
<xs:selector xpath="./Headers"/>
<xs:field xpath="e1"/>
</xs:key>
<xs:keyref name="fKey" refer="key1">
<xs:selector xpath="./Details"/>
<xs:field xpath="e1"/>
</xs:keyref>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="Headers">
<xs:complexType>
<xs:sequence>
<xs:element name="e1" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="Details">
<xs:complexType>
<xs:sequence>
<xs:element name="e1" type="xs:string"/>
<xs:element name="e2" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Thanks,
Priya

"Tomas Rivas" <to*********@tycohealthcare.com> wrote in messagenews:2c****************************@phx.gbl...
I am trying to validate an xml file and schema and when I am trying to validate I am getting the following error. I have been trying to come out with a solution but I have
failed so far. The document validates ok in xmlSpy but it fails in VS2003. Is there any article or fix for this?

Thnaks in advance.

Error:
======
"The Keyref 'Details' cannot find referred key or unique in scope. An error occurred at file:///C:/test1.xml, (7, 4)..\n"
XML file:
<?xml version="1.0" encoding="UTF-8"?>
<Renewals>
<Renewal>
<Headers>
<e1>String</e1>
</Headers>
<Details>
<e1>String</e1>
<e2>0</e2>
</Details>
</Renewal>
</Renewals>

XSD file:
=========
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 rel. 4 U
(http://www.xmlspy.com) by Tomas Rivas (Tyco Healthcare- Kendall) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="Renewals">
<xs:annotation>
<xs:documentation>Renewal
document</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element
name="Renewal">
<xs:complexType>

<xs:sequence>

<xs:element ref="Headers"/>

<xs:element ref="Details"/>

</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Headers">
<xs:complexType>
<xs:sequence>
<xs:element name="e1"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:key name="key1">
<xs:selector
xpath=".//Renewals/Renewal/Headers"/>
<xs:field xpath="e1"/>
</xs:key>
</xs:element>
<xs:element name="Details">
<xs:complexType>
<xs:sequence>
<xs:element name="e1"
type="xs:string"/>
<xs:element name="e2"
type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:keyref name="fKey" refer="key1">
<xs:selector
xpath=".//Renewals/Renewal/Details"/>
<xs:field xpath="e1"/>
</xs:keyref>
</xs:element>
</xs:schema>

=====================================
The code I am using is the following:
=====================================

public string ValidateXml(string inXMLLocation, string
inXSDLocation)
{
string errorsList = string.Empty;
try
{
// Read the xml file, and send this to
validator.
XmlTextReader xmlReader = new
XmlTextReader(inXMLLocation);

// load the schema file into an
XmlTextReader object
XmlTextReader xsdReader = new
XmlTextReader(inXSDLocation);
XmlSchemaCollection sc = new
XmlSchemaCollection();

// add the ValidationEventHandler to the
schema collection
sc.ValidationEventHandler += new
ValidationEventHandler(ValidationCallBack);
// add the schema to the
XmlSchemaCollection object
sc.Add("", xsdReader);
// create an XmlValidatingReader object
based on the Xml document
XmlValidatingReader rdr = new
XmlValidatingReader(xmlReader);

// set the ValidationType to a schema
rdr.ValidationType =
ValidationType.Schema;
rdr.Schemas.Add(sc);

rdr.ValidationEventHandler += new
ValidationEventHandler(ValidationCallBack);

while (rdr.Read());

errorsList = validationErrors;

//closing the readers and releasing the
handlers to the IFS docs.
//These readers were locking the files
when saving them to the IFS.
xmlReader.Close();
xsdReader.Close();
}
catch(Exception exc)
{
throw new Exception(string.Format("An
exception has occurred when executing method {0}.", (new StackFrame()).GetMethod().Name), exc);
}
finally
{}
return errorsList;
}

.

Nov 12 '05 #5

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

Similar topics

0
by: Tomas Rivas | last post by:
I am trying to validate an xml file and schema and when I am trying to validate I am getting the following error. I have been trying to come out with a solution but I have failed so far. The...
2
by: Tomas Vera | last post by:
Hello All, I'm running into a problem that I don't know how to solve (properly, at least). Our web servers are running Win2K and have Framework v1.0.3705 running on them. We have a DLL...
0
by: PeacError | last post by:
Using Microsoft Visual Studio .NET 2003, Visual C# .NET 1.1: I apologize if this question has been addressed elsewhere, but I could not find a reference to it in the search engine for this...
10
by: Skip | last post by:
Can anybody tell me if there is a list/discussion anywhere about possible problems/issues/differences when upgrading a desktop app from VS2002 to VS2003? I have an app that uses...
5
by: Stewart | last post by:
Pressing a Save Button on a Toolbar will not bind or validate the last value entered in a text box. I have found that when clicking on the Toolbar the focus in the binded text box does not leave. ...
23
by: _AnonCoward | last post by:
I'm looking to purchase VS 2005 some time in the near future. I've read a lot of grief on the web and in this ng as to the flaws and problems with the VS 2005 release (and I understand MS is coming...
1
by: Bonggoy Cruz | last post by:
We have a fairly big size ASP.NET web application that was written VB.NET. We are in the process converting the web project. We used the migration wizard included in VS 2005. I followed step by...
2
by: rajninathpatil | last post by:
Hi all, I get the following linker error when compiling a project written in VS2003. net How do I solve this ? Here are two more errors :
4
by: darrel | last post by:
Looks like we're getting Vista soon. Alas, we're still maintaining a few apps in 1.1 using VS.2003. Are there any issues? Does it run on Vista? I found this which appers that MS doesn't...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.