Re: [xsl] node kind of result tree

Subject: Re: [xsl] node kind of result tree
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 20 Jan 2013 18:50:59 -0500
At 2013-01-20 20:36 -0300, Max Toro wrote:
Excluding the use of xsl:result-document, is the result of an XSLT
transformation always a document-node() ?

The spec talks about result trees, but couldn't figure out if the tree
is always rooted at a document-node() or if a tree rooted at an
element() is allowed.

If your transformation is creating a variable, the choice is yours. You are not obliged to create a tree with a document-node() in a variable, as you can if you wish (among other choices) create a variable node sequence of one with that element being the apex of a tree (I'll avoid using the word "root" since it isn't a document-node()).

Check out my diagram on page 223 of my XSLT book ... the complete book can be found for a free preview here:

In that diagram (I cannot attach it to a post to the XSL List) you can see I've summarized the memory organization of four different declarations:

  - atomic sequence
  - node sequence
  - temporary tree
  - node set

The properties of the four kinds of declarations give you control over how you want to access the information you've put in your variable.

So, the following is a tree with three nodes, a document-node() at the top and two element nodes with nesting:

  <xsl:variable name="v1">

The following is a tree with just the two element nodes, with <test> at the apex:

  <xsl:variable name="v2" as="node()">

I hope this helps.

. . . . . . . Ken

Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture:
Crane Softwrights Ltd.  
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile:
Legal business disclaimers:

Current Thread