Linking to stylesheets in XML

We've said since this activity began that Phase 3 was going to be
devoted to the creation of a stylesheet language for what we now call
XML and that the stylesheet language would be defined by subsetting
DSSSL.  This objective hasn't changed, but it has become clear that we
need to specify one or more methods for attaching stylesheets to
documents so that people can start trying out different approaches and
that such methods properly belong to xml-lang or xml-link, not to
xml-style itself.  This message is intended to start a discussion of
how to specify these methods.

Requirements are the best place to begin; these occur to me:

1. Dsssl-o already exists, so while its refinement may be considered
the basic work of Phase 3, it can already be experimented with.  Thus,
we should attempt to standardize at least one form of association that
can be deployed fairly quickly.  A simple mechanism that associates a
single stylesheet with a given document might be very useful in this

2. CSS already exists; it can and will be used with XML documents.  So
there is a requirement that at least one mechanism for associating
stylesheets with documents be able to handle more than one stylesheet
language.  In the general case, one should be able to associate with a
given document multiple stylesheets that each use a different
stylesheet language.

3. DSSSL allows a single specification to contain multiple
stylesheets, but CSS does not, so there must be a way to point to
multiple stylesheets that use a single stylesheet language as well as
to multiple stylesheets using different stylesheet languages.

4. CSS allows for style specifications to be embedded directly in the
start-tags of the elements to which they apply.  I have argued in the
past that this will be very common in XML documents generated from
databases, but now I'm not so sure.  Do we allow this in XML
documents?  If so, how?

5. I have been informed by someone who watched a discussion of this
take place in the html-wg that there is a requirement for stylesheets
to be associated with specific parts of a document.  (Makes sense when
you think about it.)

6. The performance implications of different methods for calling in
and applying stylesheets are beyond my ken, but there surely must be
some.  The implementors among us should be careful to consider the
impact of the various approaches on the way that documents will
actually be rendered.

People should state other requirements if they can think of any.

Here are some mechanisms for associating stylesheets with documents
that have been proposed by various people.

Method 1: The stylesheet PI

This method was proposed by James Clark for use in the demonstrations
at WWW6 and has been implemented in the latest release of Jade (see and in the HyBrick HyTime/DSSSL browser
from Fujitsu Labs.  A stylesheet is associated with a document by
putting a processing instruction like this in the prolog:

   <?XML-stylesheet type="text/dsssl" href="foo.dsl"?>

The prolog might have a doctype declaration:

   <?XML version="1.0"?>
   <!DOCTYPE chapter [
      <?XML-stylesheet type="text/dsssl" href="foo.dsl"?>

Or it might not:

   <?XML version="1.0"?>
   <?XML-stylesheet type="text/dsssl" href="foo.dsl"?>

This is quick and easy, so it might qualify as the simple method for
quick deployment.  However, there appear to be problems in trying to
extend this to the specification of multiple stylesheets.  I don't
clearly understand these problems, but James does.  Pending their
resolution (if any), the current understanding is that any PI after
the first valid one is ignored.  It would seem on the face of it that
there is nothing to prevent having one PI for each stylesheet
language; the rule would simply be that the first valid PI for each
type (text/css, text/dsssl) is the one that gets used, and the
application figures out which flavor it wants.

It seems clear that we don't want to use this method to apply
stylesheets to parts of a document; this would put us back into the
position of thinking of the document as an event stream, which is one
of the HTMLish things that XML is trying to get away from.  The
current experimental convention is that any stylesheet PI encountered
outside the prolog is ignored.

Method 2: The stylesheet link

The leading alternative to the PI approach is to use some kind of
specialized link.  This has seemed so obvious to everyone that no one
has bothered to propose specific syntax for it.  I will leave this as
a challenge for the more imaginative members of the WG.  Some
questions that will need answering are:

   Does the stylesheet link go in some kind of meta section, like
   HEAD in HTML?  If so, how is that defined?

   Is a stylesheet link a normal link with a particular ROLE
   attribute?  If so, ROLE becomes an enumerated attribute type.

   Is a stylesheet link always a simple link?  Sometimes a simple
   link and sometimes an extended link?  (It's easy to think of good
   uses for extended stylesheet links.)  Always an extended link?
   Some different kind of link entirely?

Method 3: The stylesheet attribute

I can't remember anyone suggesting this alternative, but it suggests
itself as soon as you assert the requirement that stylesheets be
applicable to particular parts of a document.  If we reject the idea
that stylesheets are going to be switched on and off with PIs (I do!),
then the obvious way to indicate the scope of a stylesheet is to
associate it with a containing element.  For example:

   <chapter xml-stylesheet="foo.dsl">

Unfortunately, this doesn't leave us with any clean way to indicate
the stylesheet language unless we assume a limited number of them
(which is not unreasonable):

   <chapter xml-dsssl="foo.dsl" xml-css="bar.css">

One senses that a further level of indirection may be needed here.
When it's all over we may discover that this approach is no simpler
than using extended links to associate stylesheets with particular
container elements and probably much less general; one can imagine
using extended links to associate stylesheets with arbitrary spans
within a document, and while I don't think that this would be a
particularly good idea for DSSSL stylesheets, it might make sense for
CSS.  It's possible that the right way to attack this problem is
through some kind of "inline SUBDOC", which is not on the agenda for
1.0 but will almost certainly have to be reckoned with at some point.

If we are to enable embedded CSS style specifications on individual
elements, then special attributes would seem almost unavoidable:

   <chapter xml-css-style="color: blue">


Your thoughts and proposals are hereby solicited.

Personal note: I will be out of email contact from Saturday noon to
Monday night and then again most of the day Tuesday.  But I'm sure
that you will have this all figured out by the time I get back.


Received on Saturday, 19 April 1997 03:02:33 UTC