[Home] [By Thread] [By Date] [Recent Entries]


I need help in converting the following schema to DTD. The schema depicts a
simple case of personnel element with fname and lname using xs:all. Pl. see
below
DTD generated by XML Spy does not seem to be correct.

SCHEMA:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="fname" type="xs:string"/>
<xs:element name="lname" type="xs:string"/>
<xs:element name="personnel">
<xs:complexType>
<xs:all>
<xs:element ref="lname" minOccurs="0"/>
<xs:element ref="fname" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>

DTD generated by XML Spy:

<?xml version="1.0" encoding="UTF-8"?>
<!--DTD generated by XML Spy v4.2 U (http://www.xmlspy.com)-->
<!ELEMENT fname (#PCDATA)>
<!ELEMENT lname (#PCDATA)>
<!ELEMENT personnel (lname?, fname?)>


this is not correct because the XML below is INVALID with the DTD but valid
with the SCHEMA.

<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XML Spy v4.2 U (http://www.xmlspy.com)-->
<personnel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="D:\dtd2xs\try.xsd">
	<fname>String1</fname>
	<lname>String2</lname>
</personnel>


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member