Skip to main content

how to write XML schema for this dtd?

6 replies [Last post]
hutchbrew
Offline
Joined: 2005-04-12
Points: 0

I'm new for xml schema+jaxb. I have a problem when I gonna write a xml schema file for dtd below.

Can anyone help me?

Thanks in advance

hutchbrew

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kohsuke
Offline
Joined: 2003-06-09
Points: 0

Or you can compile that DTD directly with the JAXB
RI...

$ xjc.sh -dtd foobar.dtd

kirillcool
Offline
Joined: 2004-11-17
Points: 0

I thought that only XSD are officially supported.

kohsuke
Offline
Joined: 2003-06-09
Points: 0

Yes. That is correct. The spec only defines the compilation from XSD to Java.

But the compilation from other languages can still exploit the JAXB annotations freely, and thereby attain the same portability and the same runtime API.

The only thing you'll loose by compiling the DTD is to be able to switch to other schema compilers (whereas with XSD, you are supposed to be able to take your schema and switch to another JAXB implementation, and get the same code generated.)

pelegri
Offline
Joined: 2003-06-06
Points: 0

Is RelaxNG also supported out of the box in the RI?

If so, could you send us the equivalent code snippet for RNG?

- eduard/o

kohsuke
Offline
Joined: 2003-06-09
Points: 0

Unfortunately no, RELAX NG is not yet supported. But I'm determined to put it back at some point before FCS.

In the mean time, the DTD translates to the following RELAX NG grammar:

element big-town {
element house {
element address {text},
element street {text},
element size {
attribute subsize {"big"|"small"}?,
text
},
element comment {text}?
}*
}

(why does the forum software remove indentation!?)

kirillcool
Offline
Joined: 2004-11-17
Points: 0

You can use a tool like XMLSpy to perform conversions.
For your DTD ("other" was replaced by #REQUIRED):

The XSD is


































And sample XML is


String

String
String
String