faqts : Computers : Internet : Web : XML

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

28 of 34 people (82%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

XML: DTD: XSD: Convert: How to convert your DTD file to an (equivalent) XSD file?

Oct 12th, 2003 18:59
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 14 September 2003 - 09:25 pm ------------------

XML: DTD: XSD: Convert: How to convert your DTD file to an 
(equivalent) XSD file?

---

Method: use dtd2xsd.exe

---

Steps: Overview:

 1. -Download the file:

      dtd2xsd.exe

 2. -Run this file with your DTD file as a parameter:

      dtd2xsd.exe <your dtd filename>

 3. -This will generate a text listing (which you e.g. can redirect
     (using the '>' symbol on the MSDOS command line) e.g. to a text
     file, to edit with your favorite text editor):

      dtd2xsd.exe <your dtd filename> ><your text file>

---

Steps: Worked out:

 1. -Download the file

      dtd2xsd.exe

     Note: I did a search on the web if this was downloadable
           as a standalone application somewhere, but did not find
           this.
           How I got this tool, was by downloading the
           trial version of Sonic Stylus Studio

           
http://www.sonicsoftware.com/products/additional_software/stylus_studio
/index.ssp

           (About 40 megabyte)

           Then installing this product.

           If you do then a search for 'dtd2xsd.exe', you should find
           it on your harddisk.

 2. -Run this file with your DTD file as a parameter

     1. For example, given the following dtd file:

       <!ELEMENT MYBOOKS (BOOK+)>
       <!ELEMENT BOOK (AUTHOR,TITLE,PICTURE)>
       <!ELEMENT AUTHOR (#PCDATA)>
       <!ELEMENT PICTURE (#PCDATA)>
       <!ELEMENT TITLE (#PCDATA)>

     2. Save that file as e.g. 'book.dtd'

     3. Run dtd2xsd.exe with book.dtd as a parameter

         dtd2xsd.exe book.dtd

     4. That will generate the following text listing

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <xsd:element name="MYBOOKS">
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref="BOOK" maxOccurs="unbounded"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name="BOOK">
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref="AUTHOR"/>
    <xsd:element ref="TITLE"/>
    <xsd:element ref="PICTURE"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name="AUTHOR">
  <xsd:complexType mixed="true">
  </xsd:complexType>
 </xsd:element>

 <xsd:element name="PICTURE">
  <xsd:complexType mixed="true">
  </xsd:complexType>
 </xsd:element>

 <xsd:element name="TITLE">
  <xsd:complexType mixed="true">
  </xsd:complexType>
 </xsd:element>
</xsd:schema>

 3. -This will generate a text listing (which you e.g. can redirect
     e.g. to a text file, to edit with your favorite text editor)

     1. You can save this to a text file, via e.g.

         dtd2xsd.exe book.dtd >c:\temp.txt

     2. And then edit it in your favorite texeditor
        by loading this text file

         g32.exe c:\temp.txt

---
---

Method: use XMLSpy

http://www.xmlspy.com

---

[kn, ni, su, 25-05-2003 08:31:06]

---

Steps: Overview:

 1. -select your DTD document

 2.  -select from menu option 'DTD/Schema'

 3.   -select from list 'Convert DTD/Schema'

 4.    -choose e.g. 'XML-Data',

        (further possibilities are:

         -'DTD'

         -'DCD'

         -'BizTalk Schema'

         -'W3C Schema'

 5.     -to view this as text, choose:

         1. -select from menu option 'View'

         2.  -select from list 'Text View'

----------------------------------------------------------------------