[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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:

http://www.CraneSoftwrights.com/training/#ptux

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">
    <test><abc/></test>
  </xsl:variable>

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

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

I hope this helps.

. . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal


Current Thread
Keywords