How to mix use namespace and DTD?

J

jacksu

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

Joseph Kesselman

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

Richard Tobin

Joseph Kesselman said:
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
 
J

Joseph Kesselman

Richard said:
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.
 
P

Peter Flynn

Joseph said:
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
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top