how to make use of multiple dtd in a single xml file...

P

prasannadhoj

Dear all,

I am newbie in XML world , and i've an issue, i want to use 3 dtd
files in my xml.
All these 3 dtd have their own root element.

My idea was to keep one file Internal , 2nd one external in main xml
file, and third dtd to call in 2nd dtd using parameterized entity. but
i am not able to do so cause , here the root of all files comes into
picture.? Now, my questions is how to resolve this Root element from
these 3 dtds .
Another issue one of the DTDs have common element , which will makes
me uneasy always "with error DUPLICATE ELEMENT declaration not
allowed? now , xml name space comes into picture, but how do i use it
in my xml along with the dtd?
Any suggestion ,advice will be really appreciate
Thanks in Advance .

keta.
 
P

Peter Flynn

Dear all,

I am newbie in XML world , and i've an issue, i want to use 3 dtd
files in my xml.

See the XML FAQ at http://xml.silmaril.ie/developers/dtdincludes/
All these 3 dtd have their own root element.

There is no problem in a DTD having more than one root element type.
Lots of them do this (DocBook, for example).
My idea was to keep one file Internal , 2nd one external in main xml
file, and third dtd to call in 2nd dtd using parameterized entity. but
i am not able to do so cause , here the root of all files comes into
picture.? Now, my questions is how to resolve this Root element from
these 3 dtds .

You will need to parameterize them so that you can turn portions of them
on or off in the internal subset of a document or in an external
"driver" DTD. This is often a non-trivial task and requires some
in-depth knowledge.
Another issue one of the DTDs have common element , which will makes
me uneasy always "with error DUPLICATE ELEMENT declaration not
allowed?

You must arrange things so that this does not happen. Parameterization
is the normal method.
now , xml name space comes into picture, but how do i use it
in my xml along with the dtd?

DTDs are not namespace-sensitive. You can sometimes fake it simply by
parameterizing the prefixing of a string plus a colon to element type
declarations, but it's messy.

Why did you want to combine three DTDs? If it's significantly important,
I suggest you rewrite them into one DTD.

///Peter
 
J

Joe Kesselman

Peter said:
DTDs are not namespace-sensitive.

The Namespaces working group looked at what it would take to make DTDs
tolerate that concept and decided there simply was no way to make the
two ideas compatable.

The advice ever since has been: If you care about namespaces, dump DTDs
and switch to XML Schmas (or give up on validation and just use
well-formed docs).

(Schemas also handle mix-and-match/modular language specs a bit more
elegantly than DTDs can.)
 
P

Peter Flynn

Joe said:
The Namespaces working group looked at what it would take to make DTDs
tolerate that concept and decided there simply was no way to make the
two ideas compatible.

The advice ever since has been: If you care about namespaces, dump DTDs
and switch to XML Schemas (or give up on validation and just use
well-formed docs).

Personally I'd recommend RelaxNG, from which you can generate both DTD
syntax and Schema syntax. But if the OP is unable to merge three
(unparamaterized) DTDs, I think switching direct to W3C Schemas at too
early a stage is possibly going to cause even more problems. Ultimately
it's understanding the concepts of a hierarchical model which need to be
mastered, and then the syntax you express it in.

///Peter
 
P

prasannadhoj

Thank you, Peter.

As you said in the first reply, i modified the DTD, something like
this, i made 1 dtd file as "a.mod" or "a.ent" and called this file to
"b.dtd" and called in my xml file then declared the third dtd in
internal subset, added one my own Root element and keep all other
roots in my root element, then i validate my xml file with the all the
dtds.It works.

but i've seen and i would like to know why people makes " . ent" or
" .mod" file and though they contains elements, entities,attribute
list etc. just like any other dtd?


Cheer !
Thanks again.
 
P

Peter Flynn

Thank you, Peter.

As you said in the first reply, i modified the DTD, something like
this, i made 1 dtd file as "a.mod" or "a.ent" and called this file to
"b.dtd" and called in my xml file then declared the third dtd in
internal subset, added one my own Root element and keep all other
roots in my root element, then i validate my xml file with the all the
dtds.It works.

but i've seen and i would like to know why people makes " . ent" or
" .mod" file and though they contains elements, entities,attribute
list etc. just like any other dtd?

Because they're not "just like any other DTD" -- or at least they
shouldn't be.

Have a look at the .mod files in DocBook, or the .dtd and .ent files
in TEI.

They are essentially fragments which can be combined into a DTD.
IMHO only files which can be used in a SYSTEM identifier should
actually end in .dtd (but others may disagree).

///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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top