Assembling composite DTDs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy Dingley

    Assembling composite DTDs

    How can I best make a composite DTD by including one DTD inside another
    ?

    There's a pre-existing DTD in an external Apache project. I'd like to
    make use of this within our internal project, suitably extended and
    wrapped. With the aid of an internal and external subset I can do
    this, as follows:

    <?xml version="1.0"?>
    <!DOCTYPE Container
    PUBLIC "-//Apache Software Foundation//DTD OJB Repository//EN"
    "http://db.apache.org/ojb/repository.dtd"
    [
    <!-- Wrapper element -->
    <!ELEMENT Container (jdbc-connection-descriptor) >

    <!-- Remove the attribute we don't want -->
    <!ATTLIST jdbc-connection-descriptor jcd-alias CDATA #IMPLIED[color=blue]
    >[/color]

    <!-- Add a couple of attributes we do want -->
    <!ATTLIST jdbc-connection-descriptor schema CDATA #IMPLIED[color=blue]
    >[/color]
    <!ATTLIST jdbc-connection-descriptor displayname CDATA #IMPLIED[color=blue]
    >[/color]

    ]>
    <Container>
    <jdbc-connection-descriptor
    platform="Oracl e"
    jdbc-level="3.0"
    driver="@DRIVER _NAME@"
    dbalias="@URL_D BALIAS@"
    username="@USER _NAME@"
    password="@USER _PASSWD@"
    schema="@DB_SCH EMA"
    displayname="@D B_NAME"
    />
    </Container>



    Now obviously I don't want to have to repeat this internal subset into
    every one of our documents. I'd like to make a local DTD that
    represents this combination of internal and external subsets, as a
    single DTD that I can refer to from other documents. Is there any way
    to do this?

    AFAIK, it's possible to do this, but _only_ if the original DTD was
    written with that in mind (DocBook is an example) and it was already
    written as modularised components that defined entitites representing
    the DTD content and would be expanded in a wrapper DTD. Changing the
    wrapper DTD allows you to incorporate the same entities, but manipulate
    them however you like. In the simple case though, the DTD is inflexible
    except by the rather clumsy way I've done it above.

    Is this the best I can do? Should I look at a port to XML Schema
    instead?

    Apologies for the x-post to c.i.w.a.h, but the traffic there catches
    the eyeballs of some people whose opinion I'd respect on this.

  • Joe Kesselman

    #2
    Re: Assembling composite DTDs

    Andy Dingley <dingbat@codesm iths.com> wrote:[color=blue]
    > AFAIK, it's possible to do this, but _only_ if the original DTD was
    > written with that in mind[/color]

    I believe that's correct.


    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry

    Comment

    • Benjamin Niemann

      #3
      Re: Assembling composite DTDs

      Andy Dingley wrote:
      [color=blue]
      > How can I best make a composite DTD by including one DTD inside another
      > ?
      >
      > There's a pre-existing DTD in an external Apache project. I'd like to
      > make use of this within our internal project, suitably extended and
      > wrapped. With the aid of an internal and external subset I can do
      > this, as follows:
      >
      > <?xml version="1.0"?>
      > <!DOCTYPE Container
      > PUBLIC "-//Apache Software Foundation//DTD OJB Repository//EN"
      > "http://db.apache.org/ojb/repository.dtd"
      > [
      > <!-- Wrapper element -->
      > <!ELEMENT Container (jdbc-connection-descriptor) >
      >
      > <!-- Remove the attribute we don't want -->
      > <!ATTLIST jdbc-connection-descriptor jcd-alias CDATA #IMPLIED[color=green]
      >>[/color]
      >
      > <!-- Add a couple of attributes we do want -->
      > <!ATTLIST jdbc-connection-descriptor schema CDATA #IMPLIED[color=green]
      >>[/color]
      > <!ATTLIST jdbc-connection-descriptor displayname CDATA #IMPLIED[color=green]
      >>[/color]
      >
      > ]>
      > <Container>
      > <jdbc-connection-descriptor
      > platform="Oracl e"
      > jdbc-level="3.0"
      > driver="@DRIVER _NAME@"
      > dbalias="@URL_D BALIAS@"
      > username="@USER _NAME@"
      > password="@USER _PASSWD@"
      > schema="@DB_SCH EMA"
      > displayname="@D B_NAME"
      > />
      > </Container>
      >
      >
      >
      > Now obviously I don't want to have to repeat this internal subset into
      > every one of our documents. I'd like to make a local DTD that
      > represents this combination of internal and external subsets, as a
      > single DTD that I can refer to from other documents. Is there any way
      > to do this?[/color]

      Create a file, e.g. my.dtd with (untested code warnings!!)

      <!-- this will include the repository.dtd -->
      <!ENTITY % repository.dtd
      PUBLIC "-//Apache Software Foundation//DTD OJB Repository//EN"
      "http://db.apache.org/ojb/repository.dtd" >
      repository.dtd;

      <!-- add your own declarations here -->
      <!-- Wrapper element -->
      [...snip...]


      and use it as in
      <!DOCTYPE Container SYSTEM "path/to/my.dtd">

      [color=blue]
      > AFAIK, it's possible to do this, but _only_ if the original DTD was
      > written with that in mind (DocBook is an example) and it was already
      > written as modularised components that defined entitites representing
      > the DTD content and would be expanded in a wrapper DTD. Changing the
      > wrapper DTD allows you to incorporate the same entities, but manipulate
      > them however you like. In the simple case though, the DTD is inflexible
      > except by the rather clumsy way I've done it above.[/color]

      If the DTD is designed for customizations, you could declare parameter
      entities before including the DTD to adjust some things to you own needs.
      If the DTD is not designed for customizations, you can still add attributes,
      entities, etc. but the possibilities are rather limited.


      --
      Benjamin Niemann
      Email: pink at odahoda dot de
      WWW: http://pink.odahoda.de/

      Comment

      • Peter Flynn

        #4
        Re: Assembling composite DTDs

        Andy Dingley <dingbat@codesm iths.com> wrote:[color=blue]
        > How can I best make a composite DTD by including one DTD inside another
        > ?[/color]

        See the FAQ on exactly this: http://xml.silmaril.ie/developers/dtdincludes/


        ///Peter
        --
        XML FAQ: http://xml.silmaril.ie/

        Comment

        • Henri Sivonen

          #5
          Re: Assembling composite DTDs

          In article <1149244081.238 171.118190@g10g 2000cwb.googleg roups.com>,
          "Andy Dingley <dingbat@codesm iths.com>" <dingbat@codesm iths.com>
          wrote:
          [color=blue]
          > Should I look at a port to XML Schema instead?[/color]

          If you decide to abandon DTDs, RELAX NG is likely to be a better choice
          than W3C XML Schema. And the Compact Syntax is even human-writable.

          See:



          --
          Henri Sivonen
          hsivonen@iki.fi

          Validation Service for RELAX NG: http://hsivonen.iki.fi/validator/

          Comment

          Working...