Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Assembling composite DTDs

Reply
Thread Tools

Assembling composite DTDs

 
 
Andy Dingley
Guest
Posts: n/a
 
      06-02-2006
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
>


<!-- Add a couple of attributes we do want -->
<!ATTLIST jdbc-connection-descriptor schema CDATA #IMPLIED
>

<!ATTLIST jdbc-connection-descriptor displayname CDATA #IMPLIED
>


]>
<Container>
<jdbc-connection-descriptor
platform="Oracle"
jdbc-level="3.0"
driver="@DRIVER_NAME@"
dbalias="@URL_DBALIAS@"
username="@USER_NAME@"
password="@USER_PASSWD@"
schema="@DB_SCHEMA"
displayname="@DB_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.

 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      06-02-2006
Andy Dingley <> wrote:
> AFAIK, it's possible to do this, but _only_ if the original DTD was
> written with that in mind


I believe that's correct.


--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
 
 
 
Benjamin Niemann
Guest
Posts: n/a
 
      06-02-2006
Andy Dingley wrote:

> 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
>>

>
> <!-- Add a couple of attributes we do want -->
> <!ATTLIST jdbc-connection-descriptor schema CDATA #IMPLIED
>>

> <!ATTLIST jdbc-connection-descriptor displayname CDATA #IMPLIED
>>

>
> ]>
> <Container>
> <jdbc-connection-descriptor
> platform="Oracle"
> jdbc-level="3.0"
> driver="@DRIVER_NAME@"
> dbalias="@URL_DBALIAS@"
> username="@USER_NAME@"
> password="@USER_PASSWD@"
> schema="@DB_SCHEMA"
> displayname="@DB_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?


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">


> 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.


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/
 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      06-02-2006

Benjamin Niemann wrote:
> Create a file, e.g. my.dtd with (untested code warnings!!)


With the tiny change (typo?) of adding "%" to the entity reference, I
think that's doing the trick
Tested with jEdit's validator so far.

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

Thanks very much! My problem appears solved and I learned something
about DTDs.

 
Reply With Quote
 
Peter Flynn
Guest
Posts: n/a
 
      06-02-2006
Andy Dingley <> wrote:
> How can I best make a composite DTD by including one DTD inside another
> ?


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


///Peter
--
XML FAQ: http://xml.silmaril.ie/
 
Reply With Quote
 
Henri Sivonen
Guest
Posts: n/a
 
      06-03-2006
In article < .com>,
"Andy Dingley <>" <>
wrote:

> Should I look at a port to XML Schema instead?


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:
http://www.imc.org/ietf-xml-use/mail.../msg00217.html
http://lists.xml.org/archives/xml-de.../msg00057.html

--
Henri Sivonen

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

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
jar assembling tool ...? Malte Java 9 04-25-2005 06:47 AM
Assembling a Message from System.in (Standard Input) Rogue Chameleon Java 6 10-05-2004 08:03 PM
Problem assembling new computer 1st-timer Computer Support 15 03-07-2004 10:45 PM
Problem assembling new computer Palindrome Computer Support 4 03-06-2004 08:10 AM
Good SGML DTD viewer *or* tool for translating SGML DTDs to XML DTDs Clifford W. Racz XML 4 02-13-2004 06:24 PM



Advertisments