tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: DTD for server.xml??
Date Thu, 09 Jan 2003 18:17:55 GMT


On Thu, 9 Jan 2003, Martin Jacobson wrote:

> Date: Thu, 09 Jan 2003 16:06:27 +0100
> From: Martin Jacobson <martin_j@libero.it>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> Subject: Re: DTD for server.xml??
>
> Craig R. McClanahan wrote:
> >
> > On Wed, 8 Jan 2003, Turner, John wrote:
> >
> >
> >>Date: Wed, 8 Jan 2003 11:31:16 -0500
> >>From: "Turner, John" <JTurner@AAS.com>
> >>Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> >>To: "'tomcat-user@jakarta.apache.org'" <tomcat-user@jakarta.apache.org>
> >>Subject: DTD for server.xml??
> >>
> >>
> >>Hello -
> >>
> >>I notice that the top of web.xml has:
> >>
> >><?xml version="1.0" encoding="ISO-8859-1"?>
> >><!DOCTYPE web-app
> >>     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> >>     "http://java.sun.com/dtd/web-app_2_3.dtd">
> >>
> >>yet the top of server.xml has nothing.
> >>
> >>I'm very new to XML, so forgive me if this is a lame or FA question, but is
> >>there a DTD for server.xml?  If so, why isn't it specified in server.xml,
> >>and what is the URL?  Is server.xml "real, official XML" or just
> >>"convenience" XML?
> >>
> >
> >
> > There is no DTD for server.xml because there cannot be.
> >
> > The problem is that server.xml is extensible -- for example, the set of
> > attributes recognized by a <Valve> or <Context> element depends on the
> > implementation class of the internal component that corresponds to it.
> > The startup process uses Java reflection to match them up to property
> > setters on the corresponding beans.  There is no way to express this kind
> > of thing in a DTD.
> >
> > Your server.xml is (and must be) "well formed" XML.  It just cannot be
> > validated.
> >
>
> There may be other good reasons, but this isn't one of them :-)
> Here is an extract from my server.xml...
> <Logger className="org.apache.catalina.logger.FileLogger"
>   prefix="catalina_log." suffix=".txt"
>   timestamp="true"
> />
>
> This could be equally well expressed as
> <Logger className="org.apache.catalina.logger.FileLogger">
>    <property>
>      <property-name>prefix</property-name>
>      <property-value>catalina_log.</property-value>
>    </property>
>    <property>
>      <property-name>suffix</property-name>
>      <property-value>.txt</property-value>
>    </property>
>    <property>
>      <property-name>timestamp</property-name>
>      <property-value>true</property-value>
>    </property>
> </Logger>
>
> or, more concisely as
>
> <Logger className="org.apache.catalina.logger.FileLogger">
>    <property name="prefix" value="catalina_log."/>
>    <property name="suffix" value=".txt"/>
>    <property name="timestamp" value="true"/>
> </Logger>
>
> In both cases, the abstraction of property names allows a DTD to be
> defined that is inherently extensible, and thus would allow an XML
> parser to validate server.xml even if extended by an admin.
>
> Or am I missing something?
>

Well, most people edit server.xml by hand, and even your more "concise"
version is a lot of extra typing :-).  It also doesn't cover the case
where a <Listener> element that you might have dynamically creates some
new digester rules (commons-digester is what Tomcat uses to read
server.xml and web.xml files) to recognize additional elements on the fly.

The right answer to editing server.xml files is to not do it -- let a tool
do it for you.  That way, the syntax is irrelevant to the user.

> Martin

Craig



--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message