RE: [xsl] [XSL] Two "Philisophical" questions about the language

Subject: RE: [xsl] [XSL] Two "Philisophical" questions about the language
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 17 Jan 2009 16:50:05 -0000
> First one
> --------------
> We've got an instruction :
> <xsl:if>
> But this instruction has no <xsl:else> as any other language 
> I've used.

It's almost impossible to give a historically correct answer as to why the
design was done the way it was (let alone one that is backed by evidence).
One can only speculate. First, let's say one started with the "obvious"

<xsl:if test="condition">

One can well imagine someone saying this is too verbose to test a sequence
of alternative conditions (the "else if" pattern), so let's introduce
xsl:choose which handles the above case just as well and is more general;
and it's too verbose for a simple one-way test, so let's introduce xsl:if as
a shorthand with the syntax it ended up with.

> Second one
> ------------------
> My second one might be easier!
> Let's say I have an XML like this
> <?xml version="1.0">
> <root>
>   <!-- Any number of nodes here -->
> </root>
> As a valid XML document can have only one "main" node, ...
> Is there ideas to "extend" XML and allow multiple topmost 
> nodes ? 

A document *can* have multiple topmost nodes (children of the document
node). It's just that only one of them can be an element node (the others
must be comments or processing instructions). Like many people, I think
that's a silly restriction - I think it's there because at the time XML was
invented, it was considered very important that an XML document should be a
valid SGML document.

Michael Kay

Current Thread