This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: xalan error with plain text


Hi Christian,

> I don't know about the exception, but I think you do not have a
> template for the document root. So, you should at least add
>
> <xsl:template match="/">
>     <xsl:apply-templates />
> </xsl:template>
>
> This is what cost me some time to figure out: <document /> is not
> the document root, but the one and only child of the document root.
> And it's the document root where the processor starts to work.

It's true that the processor starts from the document node. But it's
almost never a problem if you don't specify a template that matches
this node - the built-in template for the root node is exactly the
same as that above, so you only *have* to specify it if you've got
some other template, somewhere else in your stylesheet, that matches
the document node and does something different.

[Also note that the document node can have more than one child - there
might be comments and processing instructions before or after the
top-level (document) element, and these are also children of the
document node. Indeed, there's actually nothing stopping XSLT from
working on documents with more than one top-level element, but you
have to pass them to the processor through code rather than as
serialized XML documents.]

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]