I tried validating my XML file with a XSD file but I get the following error message:
[Error]: cvc-complex-type.2.3: Element \'paragraph\' cannot ha
This is precisely the purpose of mixed content:
<xs:element name="paragraph" maxOccurs="unbounded">
<xs:complexType mixed="true">
And:
<xs:element name="definition" maxOccurs="unbounded">
<xs:complexType mixed="true">
Note that you also probably want paragraph
and definition
to be in a xs:choice macOccurs="unbounded"
given your XML.
Here's your XSD updated with all changes needed so that your XML will be valid:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="biography">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="paragraph">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="name">
<xs:complexType>
<xs:sequence>
<xs:element name="first_name" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="last_name" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="emphasize" maxOccurs="unbounded" minOccurs="0" type="xs:string"></xs:element>
<xs:element name="profession" maxOccurs="unbounded" minOccurs="0" type="xs:string"></xs:element>
<xs:element name="date" minOccurs="0">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="month" type="xs:string"></xs:element>
<xs:element name="day" type="xs:int"></xs:element>
<xs:element name="year" type="xs:int"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="definition">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="term" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
For me This error happen because of the strange character in the xml When I compared two files with similar data in "BeyondCompare" tool I found unknown character which is not visible. Open faulty file in "Visual Studio Code" it showed me some special characters.
When I copy pasted the string in online tools to find special characters, I found that is a special character ().
Because of this character, I got above error. It took two weeks to find solution.