E
Eric Lilja
Hello again, I'm having a new problem converting a dtd to an xml
schema. This once is a little bit more complicated than in my previous
question.
The following file validates correctly:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE books [
<!ELEMENT books (book*)>
<!ELEMENT book (author)>
<!ATTLIST book title CDATA #REQUIRED isbn CDATA #REQUIRED>
<!ELEMENT author EMPTY>
<!ATTLIST author name CDATA #REQUIRED>
]>
<books>
<book title="Winter's Heart" isbn="123456789">
<author name="Robert Jordan"/>
</book>
<book title="Paradiset" isbn="987654321">
<author name="Liza Marklund"/>
</book>
</books>
Now I want to convert the DTD to an xml schema. Here's my failed
attempt:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="books">
<xs:complexType>
<xs:sequence>
<xs:element name="book" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="title" type="xs:string"
use="required"/>
<xs:element name="authors" minOccurs="1"
maxOccurs="1">
<xs:complexType>
<xs:attribute name="name" type="xs:string"
use="required"/>
</xs:complexType>
</xs:element>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
My validator complains:
Location: 9:20
Description: s4s-elt-invalid-content.1: The content of
'#AnonType_bookbooks' is invalid. Element 'element' is invalid,
misplaced, or occurs too often.
How do I fix this error?
- Eric
schema. This once is a little bit more complicated than in my previous
question.
The following file validates correctly:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE books [
<!ELEMENT books (book*)>
<!ELEMENT book (author)>
<!ATTLIST book title CDATA #REQUIRED isbn CDATA #REQUIRED>
<!ELEMENT author EMPTY>
<!ATTLIST author name CDATA #REQUIRED>
]>
<books>
<book title="Winter's Heart" isbn="123456789">
<author name="Robert Jordan"/>
</book>
<book title="Paradiset" isbn="987654321">
<author name="Liza Marklund"/>
</book>
</books>
Now I want to convert the DTD to an xml schema. Here's my failed
attempt:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="books">
<xs:complexType>
<xs:sequence>
<xs:element name="book" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="title" type="xs:string"
use="required"/>
<xs:element name="authors" minOccurs="1"
maxOccurs="1">
<xs:complexType>
<xs:attribute name="name" type="xs:string"
use="required"/>
</xs:complexType>
</xs:element>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
My validator complains:
Location: 9:20
Description: s4s-elt-invalid-content.1: The content of
'#AnonType_bookbooks' is invalid. Element 'element' is invalid,
misplaced, or occurs too often.
How do I fix this error?
- Eric