Next in thread → Next in month →

Re: [xml-dev] DTD 2 Schema

From
G. Ken Holman <>
To
Date
2009-07-23T18:38:51Z
ID
<>
Thread
Re: [xml-dev] DTD 2 Schema
At 2009-07-23 11:31 -0700, Paul M wrote:
>Hi:
>
>I attempted to use DTDinst on sample dtd. I always receive syntax 
>error on 1st line, column 0.
>
>Sample dtd
><!DOCTYPE note [
><!ELEMENT note (to,from,heading,body)>
><!ELEMENT to (#PCDATA)>
><!ELEMENT from (#PCDATA)>
><!ELEMENT heading (#PCDATA)>
><!ELEMENT body (#PCDATA)>
>]>
>
>
>
>p.s. any other recommend dtd 2 schema translators?

Sorry, I should have also mentioned that a DTD (document type 
definition) does *not* contain a DOCTYPE (document type declaration).

You've quoted an entire document type declaration, which is not valid 
as a standalone DTD (and never has been valid as a standalone DTD 
even though a prominent vendor supported it as such in both SGML and 
XML tools, much to the consternation of other vendors who were being 
told by customers they were wrong).

Perhaps your DTDinst you are using just needs to see a DTD and not a 
document type declaration (I am not familiar with the tool):

<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>

For example, this is the output from Trang on the above:

T:\ftemp>copy con paul.dtd
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>

^Z
         1 file(s) copied.

T:\ftemp>trang -I dtd -O xsd paul.dtd con
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
elementFormDefault="qualified">
   <xs:element name="note">
     <xs:complexType>
       <xs:sequence>
         <xs:element ref="to"/>
         <xs:element ref="from"/>
         <xs:element ref="heading"/>
         <xs:element ref="body"/>
       </xs:sequence>
     </xs:complexType>
   </xs:element>
   <xs:element name="to" type="xs:string"/>
   <xs:element name="from" type="xs:string"/>
   <xs:element name="heading" type="xs:string"/>
   <xs:element name="body" type="xs:string"/>
</xs:schema>

T:\ftemp>

I hope this helps.

. . . . . . . . Ken

--
XQuery/XSLT/XSL-FO hands-on training - Oakland, CA, USA 2009-08-03
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/x/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal
Next in thread → Next in month →