DOCTYPE

H

Hugo

Hi,

I have the following XML file

<!DOCTYPE xqsn>
<xqsn version="1.0" >
<p name="BB" >
<a>CK</a>
<pa>1</pa>
<b></b>
<d>1995</d>
</p>
</xqsn>

It is soley defined for my own application to store configuration data. I've
decided to name my DOCTYPE xqsn. The question is, is there any standard I
should use as DOCTYPE? Should I use DOCTYPE at all if it is just for a
single application but not a "open standard"? What is the DOCTYPE for?

Thanks!
 
M

Martin Honnen

Hugo said:
<!DOCTYPE xqsn>
<xqsn version="1.0" >
<p name="BB" >
<a>CK</a>
<pa>1</pa>
<b></b>
<d>1995</d>
</p>
</xqsn>

It is soley defined for my own application to store configuration data. I've
decided to name my DOCTYPE xqsn. The question is, is there any standard I
should use as DOCTYPE? Should I use DOCTYPE at all if it is just for a
single application but not a "open standard"? What is the DOCTYPE for?

You need to use the name of the root element so in your case xqsn. On
the other hand putting only <!DOCTYPE xqsn> in the document does not
make much sense, you need to add element and attribute declarations.
Otherwise you can simply drop the DOCTYPE node.
 
H

Hugo

Martin said:
You need to use the name of the root element so in your case xqsn. On
the other hand putting only <!DOCTYPE xqsn> in the document does not
make much sense, you need to add element and attribute declarations.
Otherwise you can simply drop the DOCTYPE node.

How do these declarations look like?

Thanks!
 
P

Peter Flynn

How do these declarations look like?

<?xml version="1.0"?>
<!DOCTYPE xqsn [
<!ELEMENT xqsn (p+)>
<!ATTLIST xqsn version CDATA #FIXED "1.0">
<!ELEMENT p (a,pa,b,d)>
<!ATTLIST p name CDATA #REQUIRED>
<!ELEMENT a (#PCDATA)>
<!ELEMENT pa (#PCDATA)>
<!ELEMENT b (#PCDATA)>
<!ELEMENT d (#PCDATA)>
]>
<xqsn version="1.0" >
<p name="BB" >
<a>CK</a>
<pa>1</pa>
<b></b>
<d>1995</d>
</p>
</xqsn>

Except that you haven't told us anything about whether xqsn can contain
other stuff apart from p, or if p can contain other stuff than what you
showed us...so the above is just a "best-guess" at your data model.

The objective of a DTD is to guide the creation of the documents, so that
all documents of type xqsn follow the same pattern. Assuming you are
going to want to create more than one document, it may be better to put
the DTD into a separate file, eg

----------- myxsqn.dtd ------------------------
<!ELEMENT xqsn (p+)>
<!ATTLIST xqsn version CDATA #FIXED "1.0">
<!ELEMENT p (a,pa,b,d)>
<!ATTLIST p name CDATA #REQUIRED>
<!ELEMENT a (#PCDATA)>
<!ELEMENT pa (#PCDATA)>
<!ELEMENT b (#PCDATA)>
<!ELEMENT d (#PCDATA)>
----------------------------------------------

and then each document says

<?xml version="1.0"?>
<!DOCTYPE xqsn SYSTEM "myxqsn.dtd">
<xqsn version="1.0" >
<p name="BB" >
<a>CK</a>
<pa>1</pa>
<b></b>
<d>1995</d>
</p>
</xqsn>

///Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top