473,395 Members | 2,010 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,395 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.

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 12 '06 #1
1 3940
....perhaps I should also mention that 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

"BillAtWork" wrote:
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.

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 12 '06 #2

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

Similar topics

7
by: Joe | last post by:
I have an upload file operation in the web application. UploadForm.asp is the form, and UploadAction.asp is the form processing. //UploadForm.asp <FORM NAME="InputForm"...
3
by: jhill | last post by:
i have a vb asp.net application that has been working fine for a week. if on the server box i type http://localhost/theapp, everything comes up just fine i've been continually developing. now,...
2
by: Steve M | last post by:
I am having a really strange problem. I have a site setup in a virtual directory that fails with the error below. It works on other web servers that are network load balanced with this server. I...
1
by: emon.haider | last post by:
Hi guys, I just made a web application using ASP.Net and C#. The application compiles and works fine from my workstation, but after I uploaded it to my webserver, I am getting an error of "the...
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 "The Page Cannot Be Found". Some legacy pages...
1
by: VMI | last post by:
I wrote a web service whose only purpose is to update a field in a table (sql server). And everything works except for the browser window that opens up with "The page cannot be displayed" error...
2
by: spam1 | last post by:
Hi all, I'm not new to ASP.NET but I'm trying to get a simple Hello World page going on IIS 6.0 on Windows 2003. I'm connecting from the local machine. It comes back with the standard "The...
2
by: jhaxo | last post by:
I have a web page that I installed to IIS 6.0 from a web deployment project successfully. I am trying to deploy the same application to laptops that are running IIS 5.0. I am getting an error...
3
maliksleo
by: maliksleo | last post by:
hi all i m having this "The resource cannot be found." error. I applied the url rewriting on my project every page is being browsed very well but i am getting the above error an some pages i dont...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...
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
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,...

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.