Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create a dtd for this xml?

Tags:

java

xml

dtd

i have been asked to create a simple dtd for this xml :

<?xml version='1.0' encoding='ISO-8859-1'?>
<QUERY>
  <PORT>
    <NB></NB>
  </PORT>
  <BLOCK>
    <TAB></TAB>
  </BLOCK>
  <STAND>
    <LEVEL></LEVEL>
  </STAND>
</QUERY>

i am using java, i've never did dtd before nor do i know precisely what does it mean. i would like some guidance if its possible, thank you

like image 403
ccot Avatar asked Dec 28 '25 22:12

ccot


1 Answers

DTD is Document Type Definition, and is used to represent the structure of you XML document. Other representations include XML Schema, Relax NG, etc.:

  • http://en.wikipedia.org/wiki/Document_Type_Definition

It will look something like the following (although my syntax may not be quite right):

<!ELEMENT QUERY (PORT, BLOCK, STAND)>
<!ELEMENT PORT (NB)>
<!ELEMENT NB (#PCDATA)>
<!ELEMENT BLOCK (TAB)>
<!ELEMENT TAB (#PCDATA)>
<!ELEMENT STAND (LEVEL)>
<!ELEMENT LEVEL (#PCDATA)>

If you look at the definition for QUERY you see it defines that it contains the elements: "PORT", "BLOCK", and "STAND". If you look at the definition for NB, we have declared that it should contain text (parsed character data).

like image 55
bdoughan Avatar answered Dec 30 '25 12:12

bdoughan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!