Discussion:
The element cannot contain text or white space. Content model is empty
(too old to reply)
j***@yahoo.com
2006-02-16 17:26:04 UTC
Permalink
I have posted the XML file and the schema file generated using XSD.exe.

When I try to validate using (C#) I get the following error.

XML Validation error: The element cannot contain text or white space.
Content model is empty. An error occurred at
file:///c:/HouseReport_2006-02-14.fpr.xml, (3, 59).

Pls note the following

<Criteria Var1="5393" Var2="2006-02-14">
</Criteria>

If I change the above line as follows, then the error goes away. But I
don't want to change the XML file because it is coming from an external
source.

<Criteria Var1="5393" Var2="2006-02-14"> </Criteria>


XML File :

<?xml version="1.0" encoding="utf-8"?>
<PostHouseReport xmlns = "SchemaFile.xsd" >
<Criteria Var1="5393" Var2="2006-02-14">
</Criteria>
<Houses>
<House HouseNo="33" HouseStatus="CLER">
<Nm last="Joe3" first="Don2" mid="C" suf="">
</Nm>
</House>
<House HouseNo="44" HouseStatus="CLER">
<Nm last="Joe4" first="DOn1" mid="" suf="">
</Nm>
</House>
</Houses>
</PostHouseReport>

Schema File :

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="HouseReport" elementFormDefault="qualified"
targetNamespace="Schwab/CLEARS/HouseReport.xsd"
xmlns="SchemaFile.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="HouseReport" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Criteria">
<xs:complexType>
<xs:attribute name="Var1" type="xs:string" />
<xs:attribute name="Var2" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="Houses">
<xs:complexType>
<xs:sequence>
<xs:element name="House" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Nm" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="last" type="xs:string" />
<xs:attribute name="first" type="xs:string" />
<xs:attribute name="mid" type="xs:string" />
<xs:attribute name="suf" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="HouseNo" type="xs:string" />
<xs:attribute name="HouseStatus" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Martin Honnen
2006-02-16 17:34:36 UTC
Permalink
Post by j***@yahoo.com
If I change the above line as follows, then the error goes away. But I
don't want to change the XML file
You would need to change the schema then to allow element content
Post by j***@yahoo.com
<xs:element name="Criteria">
<xs:complexType>
<xs:attribute name="Var1" type="xs:string" />
<xs:attribute name="Var2" type="xs:string" />
</xs:complexType>
</xs:element>
One way would be e.g.

<xs:element name="Criteria">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Var1" type="xs:string" />
<xs:attribute name="Var2" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>

which however allows any kind of string content inside of the element,
white space or non white space.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
j***@yahoo.com
2006-02-16 18:37:36 UTC
Permalink
Thanks Martin, That did the trick.
Post by Martin Honnen
Post by j***@yahoo.com
If I change the above line as follows, then the error goes away. But I
don't want to change the XML file
You would need to change the schema then to allow element content
Post by j***@yahoo.com
<xs:element name="Criteria">
<xs:complexType>
<xs:attribute name="Var1" type="xs:string" />
<xs:attribute name="Var2" type="xs:string" />
</xs:complexType>
</xs:element>
One way would be e.g.
<xs:element name="Criteria">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Var1" type="xs:string" />
<xs:attribute name="Var2" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
which however allows any kind of string content inside of the element,
white space or non white space.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
j***@yahoo.com
2006-02-16 20:59:30 UTC
Permalink
Martin, May be not... Have another issue now.

When I tried to load this schema into a .net Dataset and tried to add a
new column (in the dataset), I get the following error.

Cannot add a nested relation or an element column to a table containing
a SimpleContent column.

When I remove the simplecontent tags from the schema file then it works
fine (but the data validation fails as before).

Any thoughts?
Post by Martin Honnen
Post by j***@yahoo.com
If I change the above line as follows, then the error goes away. But I
don't want to change the XML file
You would need to change the schema then to allow element content
Post by j***@yahoo.com
<xs:element name="Criteria">
<xs:complexType>
<xs:attribute name="Var1" type="xs:string" />
<xs:attribute name="Var2" type="xs:string" />
</xs:complexType>
</xs:element>
One way would be e.g.
<xs:element name="Criteria">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Var1" type="xs:string" />
<xs:attribute name="Var2" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
which however allows any kind of string content inside of the element,
white space or non white space.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Peter Flynn
2006-02-16 23:58:31 UTC
Permalink
Post by Martin Honnen
Post by j***@yahoo.com
If I change the above line as follows, then the error goes away. But I
don't want to change the XML file
You would need to change the schema then to allow element content
I think that is fixing the symptom rather than the disease.

From what the OP said, the supplier is not providing XML data
which conforms to the Schema (which they have presumably also
supplied). In this case it is the responsibility of the supplier
to fix their broken generator, not ask the consumer to patch the
Schema :-)

///Peter
Martin Honnen
2006-02-17 11:59:36 UTC
Permalink
Post by Peter Flynn
Post by Martin Honnen
Post by j***@yahoo.com
If I change the above line as follows, then the error goes away. But I
don't want to change the XML file
You would need to change the schema then to allow element content
I think that is fixing the symptom rather than the disease.
I agree but he explictly noted in his post that the input XML could not
be changed so the only way then to get XML and schema to match is to
change the schema.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Peter Flynn
2006-02-17 22:26:52 UTC
Permalink
Post by Martin Honnen
Post by Peter Flynn
Post by Martin Honnen
Post by j***@yahoo.com
If I change the above line as follows, then the error goes away. But I
don't want to change the XML file
You would need to change the schema then to allow element content
I think that is fixing the symptom rather than the disease.
I agree but he explictly noted in his post that the input XML could not
be changed so the only way then to get XML and schema to match is to
change the schema.
Quite possibly. I was making the assumption that the schema was supplied
by the supplier of the XML too, and thus equally unamenable to change.

It can be really hard explaining to a proud but ignorant client that
they are generating garbage and pretending it's XML :-)

///Peter

Continue reading on narkive:
Loading...