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

Discussion in 'XML' started by prasannadhoj@gmail.com, Feb 24, 2007.

  1. Guest

    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.
     
    , Feb 24, 2007
    #1
    1. Advertising

  2. Peter Flynn Guest

    wrote:
    > 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
    --
    XML FAQ: http://xml.silmaril.ie/
     
    Peter Flynn, Feb 24, 2007
    #2
    1. Advertising

  3. Peter Flynn wrote:
    > 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.)

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, Feb 24, 2007
    #3
  4. Peter Flynn Guest

    Joe Kesselman wrote:
    > Peter Flynn wrote:
    >> 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 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
     
    Peter Flynn, Feb 24, 2007
    #4
  5. Guest

    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.
     
    , Feb 27, 2007
    #5
  6. Peter Flynn Guest

    wrote:
    > 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
     
    Peter Flynn, Mar 4, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joseph Tilian
    Replies:
    0
    Views:
    366
    Joseph Tilian
    Dec 21, 2004
  2. Ronald Fischer
    Replies:
    4
    Views:
    1,791
    Ronald Fischer
    Mar 17, 2005
  3. John_Woo
    Replies:
    4
    Views:
    675
    John_Woo
    Jan 24, 2006
  4. test
    Replies:
    2
    Views:
    2,128
    Oliver Wong
    Jul 28, 2006
  5. ela
    Replies:
    12
    Views:
    372
    Uri Guttman
    Apr 6, 2009
Loading...

Share This Page