Я пытался прояснить эту проблему, на данный момент я не уверен, что я запутался в пространствах имен, которые вызывают проблему, или если это что-то не так с синтаксисом кода, но все экземпляры itemNameобъявлены одинаково и все закрыты правильно.
Попытка выяснить эту ошибку:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'itemName'. One of '{itemName}' is expected.
Мой xsd-файл:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.com/chestershartland/recipe"
xmlns="http://example.com/chestershartland/recipe"
>
<xs:element name="recipe">
<xs:complexType>
<xs:sequence>
<xs:element name="itemName" type="xs:string" />
<xs:element name="ingredients">
<xs:complexType>
<xs:sequence>
<xs:element name="ingredient" type="xs:string" />
<xs:element name="ingredient" type="xs:string" />
<xs:element name="ingredient" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="directions" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
Код XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<recipe
xmlns="http://example.com/chestershartland/recipe"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.com/chestershartland/recipe recipe.xsd"
>
<itemName>Oatmeal Breakfast</itemName>
<ingredients>
<ingredient>1/3 c steel cut oats</ingredient>
<ingredient>1-1/4 c water</ingredient>
<ingredient>1/4 t salt</ingredient>
</ingredients>
<directions>
<![CDATA[Bring water to a boil. Add salt and oats, stir, and lower heat
to lowest setting. Cover and let stand 2 hours.
]]>
</directions>
</recipe>