I have a new question about the same code. Now all my words (only one in the original example, but I have more in my file) in the XML-file have id:s, like this:
<words id="wordone">clock</words>
<words id="wordtwo">sleep</words>
And now I have to change the code in my XML-schema too, but I can't figure out how. I have this now:
<xsd:element name="words" type="xsd:string" maxOccurs="unbounded" />
And I thought that would work, because the name of the words are still "words", but I get an error. What do I miss?
Im new at this and I need some help. :) This is my first try and my XML schema looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!-- File Name: words.xsd -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:annotation>
<xsd:documentation>
Lexicon spanish english
</xsd:documentation>
</xsd:annotation>
<xsd:element name="english">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="listwords"/>
<xsd:element name="language" type="xsd:string"/>
<xsd:element name="authur" type="xsd:string"/>
<xsd:element name="allwords" type="xsd:string"/>
<xsd:element name="words" type="xsd:string" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
and my XML-file:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="main.css"?>
<english xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="words.xsd">
<!-- Filename: english.xml -->
<!-- Authur: FL -->
<!-- Date: 2016-11-15 -->
<listwords>
<language>English</language>
<authur>FL</authur>
<allwords>
<words>clock</words>
</allwords>
</listwords>
The error: "XML document structures must start and end within the same entity."
Help? :)
You have to add </english>
at the bottom of your file:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="main.css"?>
<english xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="words.xsd">
<!-- Filename: english.xml -->
<!-- Authur: FL -->
<!-- Date: 2016-11-15 -->
<listwords>
<language>English</language>
<authur>FL</authur>
<allwords>
<words>clock</words>
</allwords>
</listwords>
</english>