Convert DTD to XML / Generate XML instances from DTD

Questions about XML that are not covered by the other forums should go here.
heavydawson
Posts: 14
Joined: Wed Sep 20, 2006 7:07 pm

Convert DTD to XML / Generate XML instances from DTD

Post by heavydawson »

Hey all,
I'm wondering if it's possible to convert a DTD to XML as is possible with Stylus:
http://www.stylusstudio.com/dtd/dtd_to_xml.html
Also I'm wondering if the possibility is available to generate XML instances from DTD. I'm aware they exist for generating XML instances from XML Schema, but generating from DTD would also be useful.

If neither feature is available, then I'll move this to the feature request forum.
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Post by Dan »

Hello,

Each time you create a new XML file based on a DTD, oXygen generates the required content for the root element automatically. There is no need for a new tool.

Let's take for example the following DTD:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT a (b,c,d) >
<!ELEMENT b (x|y) >
<!ATTLIST b b_attr CDATA #REQUIRED>

<!ELEMENT x (t,w)>
<!ATTLIST x x_attr CDATA #REQUIRED>

<!ELEMENT c (#PCDATA)>
<!ELEMENT d (#PCDATA)>
<!ELEMENT y (#PCDATA)>
<!ELEMENT w (#PCDATA)>
<!ELEMENT t (#PCDATA)>
We have severeal required attributes. The b element is a choice between x and y.
To generate an XML instance based on this DTD, go to the File menu/New, choose XML from the list, then in the XML document configuration wizard select the DTD and check the checkboxes: "Add optional content" and "Add first Choice particle". Just like in the following screenshot:Image
The created document is:

Code: Select all


<a>
<b b_attr="">
<x x_attr="">
<t></t>
<w></w>
</x>
</b>
<c></c>
<d></d>
</a>
Regards,
Dan
Post Reply