You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ben Laurie <be...@algroup.co.uk> on 2000/01/11 22:36:12 UTC

A Somewhat Incoherent XML Configuration Proposal

I've been thinking about this on and off ever since it was first mooted,
and I think I have the germs of an idea. First off, there's The Problem.
The Problem is that each module should really have a free hand to define
its own XML, but if it does that, how do we know which module to feed it
to? Well, I have a simple solution to that. We wrap module-specific
directives up in chunks that clearly belong to the module, like so:

<Apache>
  <Module name="somemodule">
    .
    .
  </Module>
  <Module name="someothermodule">
    .
    .
  </Module>
</Apache>

there... that was easy! Now, the astute reader will say "Aha! But what
about <VirtualHost...> and <Location...> and the like?" - well spotted
... these can be handled relatively trivially (I think) - they simply
wrap valid configuration XML, and the module that handles them decides
whether the enclosed XML is processed for the current request, or not,
depending on whether they "match". As in the current architecture, the
directives will build up a configuration that is cached according to the
context, so that also deals with the efficiency problem (i.e. the XML
won't get reprocessed for every request, only when the context is
novel).

Going a little further, I think it would be possible to generalize the
VirtualHost stuff, at al., into "context variables", along these lines:

  <Module name="if">
    <If host="somewhere.nowhere.com" port="1234">
       .
       .
    </If>
  </Module>

the resulting configuration would be cached against the values of the
context variables, so when the same setup occurred, the configuration
would be reused...

Not only would this be rather flexible, but I suspect it would remove a
good deal of the arcane code that currently handles vhosts, locations,
files and so forth...

But before I elaborate on this basic scheme, I'd like some feedback...

Cheers,

Ben.

--
SECURE HOSTING AT THE BUNKER! http://www.thebunker.net/hosting.htm

http://www.apache-ssl.org/ben.html

"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi

Re: A Somewhat Incoherent XML Configuration Proposal

Posted by Martin Pool <mb...@linuxcare.com.au>.
On Tue, Jan 11, 2000 at 09:36:12PM +0000, Ben Laurie wrote:
> I've been thinking about this on and off ever since it was first mooted,
> and I think I have the germs of an idea. First off, there's The
> Problem.

> The Problem is that each module should really have a free hand to define
> its own XML, but if it does that, how do we know which module to feed it
> to? 

I think the solution most in tune with XML would be to use XML
namespaces, and to allow each module to define its own tags within its
namespace.  The XML RFC lays down some rules about how applications
should handle tags they don't understand, how to define namespaces and
so on. 

See for example

  http://www.w3.org/TR/REC-xml-names/

(I do sometimes think w3c doesn't always pay enough care to
simplicitly, and perhaps this is an example.)

> Well, I have a simple solution to that. We wrap module-specific
> directives up in chunks that clearly belong to the module, like so:

The problem with that approach is that it conflates ``which module
defined this directive'' with the semantic structure of the
configuration. 

<Apache>
  <Directory name="/usr/doc">
    <autoindex:ReadmeName filename="README"/>
    <expires:ExpiresActive enable="yes"/>
    <expires:ExpiresDefault seconds="38400"/>
  </Directory>
</Apache>

> Going a little further, I think it would be possible to generalize the
> VirtualHost stuff, at al., into "context variables", along these lines:
> 
>   <Module name="if">
>     <If host="somewhere.nowhere.com" port="1234">
>        .
>        .
>     </If>
>   </Module>

Instead I would write

<Apache>
  <LoadModule module="mod_if"/>
  ...
  <if:ListenPort host="somewhere.outthere.com" port="1234">
     ...
  </if:ListenPort>
</Apache>

The parser should handle most of the work of this for us.

At any rate, this seems like the correct XML way to do it.  That
doesn't make it the best, of course.

> the resulting configuration would be cached against the values of the
> context variables, so when the same setup occurred, the configuration
> would be reused...
> 
> Not only would this be rather flexible, but I suspect it would remove a
> good deal of the arcane code that currently handles vhosts, locations,
> files and so forth...
> 
> But before I elaborate on this basic scheme, I'd like some
> feedback...

There you go.

-- 
Martin Pool, Technical Support Engineer, Linuxcare, Inc.
+61 2 6262 8990
mbp@linuxcare.com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.

Re: A Somewhat Incoherent XML Configuration Proposal

Posted by David Reid <ab...@dial.pipex.com>.
I'd been wondering about something akin to this myself...though you have
explained it much clearer than I ever could have :-)

david
----- Original Message -----
From: "Ben Laurie" <be...@algroup.co.uk>
To: "Apache List" <ne...@apache.org>
Sent: Tuesday, January 11, 2000 9:36 PM
Subject: A Somewhat Incoherent XML Configuration Proposal


> I've been thinking about this on and off ever since it was first mooted,
> and I think I have the germs of an idea. First off, there's The Problem.
> The Problem is that each module should really have a free hand to define
> its own XML, but if it does that, how do we know which module to feed it
> to? Well, I have a simple solution to that. We wrap module-specific
> directives up in chunks that clearly belong to the module, like so:
>
> <Apache>
>   <Module name="somemodule">
>     .
>     .
>   </Module>
>   <Module name="someothermodule">
>     .
>     .
>   </Module>
> </Apache>
>
> there... that was easy! Now, the astute reader will say "Aha! But what
> about <VirtualHost...> and <Location...> and the like?" - well spotted
> ... these can be handled relatively trivially (I think) - they simply
> wrap valid configuration XML, and the module that handles them decides
> whether the enclosed XML is processed for the current request, or not,
> depending on whether they "match". As in the current architecture, the
> directives will build up a configuration that is cached according to the
> context, so that also deals with the efficiency problem (i.e. the XML
> won't get reprocessed for every request, only when the context is
> novel).
>
> Going a little further, I think it would be possible to generalize the
> VirtualHost stuff, at al., into "context variables", along these lines:
>
>   <Module name="if">
>     <If host="somewhere.nowhere.com" port="1234">
>        .
>        .
>     </If>
>   </Module>
>
> the resulting configuration would be cached against the values of the
> context variables, so when the same setup occurred, the configuration
> would be reused...
>
> Not only would this be rather flexible, but I suspect it would remove a
> good deal of the arcane code that currently handles vhosts, locations,
> files and so forth...
>
> But before I elaborate on this basic scheme, I'd like some feedback...
>
> Cheers,
>
> Ben.
>
> --
> SECURE HOSTING AT THE BUNKER! http://www.thebunker.net/hosting.htm
>
> http://www.apache-ssl.org/ben.html
>
> "My grandfather once told me that there are two kinds of people: those
> who work and those who take the credit. He told me to try to be in the
> first group; there was less competition there."
>      - Indira Gandhi


Re: A Somewhat Incoherent XML Configuration Proposal

Posted by Ben Laurie <be...@algroup.co.uk>.
Rasmus Lerdorf wrote:
> 
> >   <Module name="if">
> >     <If host="somewhere.nowhere.com" port="1234">
> >        .
> >        .
> >     </If>
> >   </Module>
> 
> What is this "if" module name?  Your suggestion makes sense to me, but
> this confused me.

It's the one that implements the <If...> XML thing... currently "core"
would be the right name, but I was allowing for different
implementations of conditionals.

Cheers,

Ben.

--
SECURE HOSTING AT THE BUNKER! http://www.thebunker.net/hosting.htm

http://www.apache-ssl.org/ben.html

"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi

Re: A Somewhat Incoherent XML Configuration Proposal

Posted by Rasmus Lerdorf <ra...@apache.org>.
>   <Module name="if">
>     <If host="somewhere.nowhere.com" port="1234">
>        .
>        .
>     </If>
>   </Module>

What is this "if" module name?  Your suggestion makes sense to me, but
this confused me.

-Rasmus