How to mix use namespace and DTD?

Discussion in 'XML' started by jacksu, Mar 3, 2008.

  1. jacksu

    jacksu Guest

    I need namespace because I need to define other namespace ("http://
    www.springframework.org/schema/aop") within root name space "http://
    www.springframework.org/schema/beans").

    and at the same time, I need entity feature in DTD, so that I could
    use "entity" function to separate xml files into several pieces.

    Here is what I am struggling with:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
    "http://www.springframework.org/dtd/spring-beans-2.0.dtd" [
    <!ENTITY module1 SYSTEM "module1.inc">
    <!ENTITY module2 SYSTEM "module2.inc">
    ]>
    <beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"
    >
    jacksu, Mar 3, 2008
    #1
    1. Advertising

  2. With great difficulty. Namespaces were designed with the knowledge that
    they would be largely incompatable with DTDs.

    Switch to XML Schema. Or accept a lot of pain. See past discussion in
    this newsgroup and on various websites.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
    Joseph Kesselman, Mar 3, 2008
    #2
    1. Advertising

  3. In article <47cc55fd$1@kcnews01>,
    Joseph Kesselman <> wrote:

    >With great difficulty. Namespaces were designed with the knowledge that
    >they would be largely incompatable with DTDs.


    DTDs themselves are not incompatible with namespaces. DTD validity
    and other aspects of element and attribute declarations are hard to
    combine with namespaces. But if you just want some entity
    declarations, it shouldn't be a problem. Just don't try to validate,
    and don't bother declaring anything except the entities.

    This is a perfectly well-formed document entity:

    <!DOCTYPE dummy [
    <!ENTITY ent SYSTEM "ent.xml">
    ]>
    <bar>&ent;</bar>

    You don't even have to get the root element name right in the DOCTYPE
    statement.

    -- Richard
    --
    :wq
    Richard Tobin, Mar 3, 2008
    #3
  4. Richard Tobin wrote:
    > DTDs themselves are not incompatible with namespaces. DTD validity
    > and other aspects of element and attribute declarations are hard to
    > combine with namespaces.


    I agree, that's a better phrasing. Sorry; explain this a few hundred
    times and it's too easy to start firing off the standard brain-dump
    without reading carefully enough.

    I still suggest moving to a Schema environment plus XInclude or
    something like that -- among other things, XInclude is namespace-aware
    and thus will properly preserve namespaces when assembling a composite
    document, rather than having the risk that a default attribute
    declaration or something of that sort will produce a different meaning
    than you intended.


    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
    Joseph Kesselman, Mar 3, 2008
    #4
  5. jacksu

    Peter Flynn Guest

    Joseph Kesselman wrote:
    > With great difficulty. Namespaces were designed with the knowledge that
    > they would be largely incompatible with DTDs.
    >
    > Switch to XML Schema. Or accept a lot of pain.


    'and', not 'or' :)

    ///Peter
    Peter Flynn, Mar 3, 2008
    #5
    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:
    352
    Joseph Tilian
    Dec 21, 2004
  2. Ronald Fischer
    Replies:
    4
    Views:
    1,758
    Ronald Fischer
    Mar 17, 2005
  3. Jimi Hullegård
    Replies:
    0
    Views:
    413
    Jimi Hullegård
    Jun 22, 2005
  4. test
    Replies:
    2
    Views:
    2,029
    Oliver Wong
    Jul 28, 2006
  5. J Krugman

    use constant and BEGIN don't mix?

    J Krugman, Apr 30, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    98
    Anno Siegel
    May 1, 2004
Loading...

Share This Page