472,341 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

XSD Validation error: "The element 'x...' cannot contain text

Hi,
I'm trying to validate an XML document against an XSD schema and I receive
the following error:

----------
MyCode.CreateValidRequest : System.Web.Services.Protocols.SoapException :
Validation error: The element 'http://xmlns.somewhere.com/something:rDetail'
cannot contain text. Expected 'http://xmlns.somewhere.com/something:AList'.
An error occurred at , (1, 533).
----------

There doesn't seem to be much information about this error - could anyone
please help? I've included the schema fragment and sample XML below.

I'm using an XmlValidatingReader to perform the validation.

e.g.
....
XmlValidatingReader vr = new XmlValidatingReader(new
XmlTextReader(message.Stream));
vr.Schemas.Add(this.schemaCache);
vr.ValidationEventHandler += this.validateEventHandler; //<--THIS gets fired
with my error message
vr.ValidationType = ValidationType.Schema;
while (vr.Read())
{
System.Diagnostics.Debug.WriteLine (vr.Name + " " + vr.Value);
} ;
....

Thanks,
Bill

---------------
---- XSD ------
---------------
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema targetNamespace="http://xmlns.somewhere.com/something"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://xmlns.somewhere.com/something"
elementFormDefault="qualified" attributeFormDefault="qualified">
<xs:element name="SomeStuff">
<xs:complexType>
<xs:sequence>
...
<xs:element name="rDetail" type="RDetail" />
...
</xs:sequence>
</xs:complexType>
</xs:element>
....
<xs:complexType name="RDetail">
<xs:choice maxOccurs="unbounded">
<xs:element name="AList">
<xs:complexType>
<xs:sequence>
<xs:element name="AListItem" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="SomeData" type="xs:string" minOccurs="0" />
</xs:sequence>
<xs:attribute name="id" form="unqualified" type="xs:string" />
<xs:attribute name="anotherAttribute" form="unqualified"
type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
....
</xs:schema>

---------------
---- XML ------
---------------
<?xml version="1.0" encoding="utf-8"?>
<RDetail xmlns="references the above schema">
<AList>
<AListItem id="theID">
<SomeData>1-2-3-4</SomeData>
</AListItem>
<AListItem id="theID">
<SomeData>something</SomeData>
</AListItem>
<AListItem id="theID">
<SomeData>a,b,c</SomeData>
</AListItem>
</AList>
</RDetail>
Jun 19 '06 #1
1 2393
Since the content of RDetali is element only , it neither allows text or any
significant whitespaces. Please make sure you do not have any whitespaces in
the content of the RDetail. I stripped your data of whitespaces, and could
validate without problems.

Zafar

"BillAtWork" <Bi********@nospam.nospam> wrote in message
news:7C**********************************@microsof t.com...
Hi,
I'm trying to validate an XML document against an XSD schema and I receive
the following error:

----------
MyCode.CreateValidRequest : System.Web.Services.Protocols.SoapException :
Validation error: The element 'http://xmlns.somewhere.com/something:rDetail' cannot contain text. Expected 'http://xmlns.somewhere.com/something:AList'. An error occurred at , (1, 533).
----------

There doesn't seem to be much information about this error - could anyone
please help? I've included the schema fragment and sample XML below.

I'm using an XmlValidatingReader to perform the validation.

e.g.
...
XmlValidatingReader vr = new XmlValidatingReader(new
XmlTextReader(message.Stream));
vr.Schemas.Add(this.schemaCache);
vr.ValidationEventHandler += this.validateEventHandler; //<--THIS gets fired with my error message
vr.ValidationType = ValidationType.Schema;
while (vr.Read())
{
System.Diagnostics.Debug.WriteLine (vr.Name + " " + vr.Value);
} ;
...

Thanks,
Bill

---------------
---- XSD ------
---------------
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema targetNamespace="http://xmlns.somewhere.com/something"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://xmlns.somewhere.com/something"
elementFormDefault="qualified" attributeFormDefault="qualified">
<xs:element name="SomeStuff">
<xs:complexType>
<xs:sequence>
...
<xs:element name="rDetail" type="RDetail" />
...
</xs:sequence>
</xs:complexType>
</xs:element>
...
<xs:complexType name="RDetail">
<xs:choice maxOccurs="unbounded">
<xs:element name="AList">
<xs:complexType>
<xs:sequence>
<xs:element name="AListItem" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="SomeData" type="xs:string" minOccurs="0" />
</xs:sequence>
<xs:attribute name="id" form="unqualified" type="xs:string" />
<xs:attribute name="anotherAttribute" form="unqualified"
type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
...
</xs:schema>

---------------
---- XML ------
---------------
<?xml version="1.0" encoding="utf-8"?>
<RDetail xmlns="references the above schema">
<AList>
<AListItem id="theID">
<SomeData>1-2-3-4</SomeData>
</AListItem>
<AListItem id="theID">
<SomeData>something</SomeData>
</AListItem>
<AListItem id="theID">
<SomeData>a,b,c</SomeData>
</AListItem>
</AList>
</RDetail>

Jun 19 '06 #2

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

Similar topics

1
by: Angel | last post by:
I'm trying to connect to a fixed IP address (eg. http://10.60.903.50/TempFile) in order to retrieve one accii line of text in TempFile. I try to...
2
by: Andreas Poller | last post by:
Hello, I have the following problem: I have a class deriving from ICustomTypeDescriptor: public __gc class TPropertyBag : public...
9
by: Martin Eyles | last post by:
Hi, I have set up an asp.net website on another PC in order to test it. The site was fine on my PC, but on the new PC all the pages give the error...
0
by: R.A.M. | last post by:
Hi, Do you know if using asp: validators I can have validation text in browser popup message box? Thank you very much for your help. /RAM/
1
by: BillAtWork | last post by:
Hi, I'm trying to validate an XML document against an XSD schema and I receive the following error: ---------- MyCode.CreateValidRequest :...
0
by: Curious | last post by:
Hi, I'm not sure if this is the right place to post such command issues. If you know a better forum where people respond to messages fairly...
5
by: mukeshrasm | last post by:
Hi I am working on gd library with PHP to create graphs which is displaying correctly. But I want to display some information about this graph as...
10
by: Roger | last post by:
ms-access97 & sql server2005 two tables tblItem tblItemFeature form frmItem contains subform frmItemFeature each form is based on their...
1
Tarantulus
by: Tarantulus | last post by:
Hi Guys, I'll keep this short and sweet: class connection{ public $database; public $username; public $password;
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.