Re: [xsl] XSLT result tree fragment, with XSLT 3.0 and xsl:variable

Subject: Re: [xsl] XSLT result tree fragment, with XSLT 3.0 and xsl:variable
From: "Piez, Wendell A. (Fed) wendell.piez@xxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 11 Apr 2023 13:38:49 -0000
Hello Mukul,

It is probably best to regard XSLT 1.0 and XSLT 3.0 as different even if there
is an historical relation. We do not expect Latin grammatical rules or even
terminology to apply perfectly to French. That's why French is French and not
Latin.

In any case, something changed historically when in the 2.0 version of the
technologies, "result tree fragment" was replaced with "temporary tree", which
appears to be much the same thing even though it is not necessarily temporary
any more than the fragment was a fragment.

The essential difference is that you were not allowed in *unextended* XSLT 1.0
to treat the fragment like a tree. In 2.0 you were invited to do so.

But keep in mind I just play the game, I don't make the rules.

Ken thanks for calling out some of the important caveats here. When seeking
clarity, it is important to keep in mind what changed and what didn't, and the
stabilization of XDM in that same time frame gave XSLT 2.0 a place to stand
that XSLT 1.0 had had to find for itself.

Cheers, Wendell

-----Original Message-----
From: G. Ken Holman g.ken.holman@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, April 10, 2023 8:33 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] XSLT result tree fragment, with XSLT 3.0 and xsl:variable

Mukul, my pedantic concerns about your text here relate to the distinction
between nodes and XML syntax.

XSLT 1.0 result tree fragments were exactly that:
fragments of the result tree of nodes ... that happen to be serialized as XML
syntax if the user intended to create XML syntax. But XSLT guides the creation
of result tree nodes from source tree nodes based on stylesheet tree nodes. If
the XSLT is an intermediate step of the manipulation of trees of content, then
XML syntax doesn't come into play.

XML only comes out if the result tree is serialized as XML (and there are
other choices, as you know, for serialization syntax).

So when you say:

 > It seems to me that, XSLT 1.0's "result tree fragment" (before  > being
serialized to the output XML) is a well-formed XML fragment.

... I don't agree it is a well-formed XML fragment. It is a fragment of a node
tree, so a bunch of nodes, which can be serialized as XML syntax, and that
serialization ensures each XML element node is well-formed.

If in the completed result tree there are zero or more than one apex element
nodes, the tree is serialized as an external XML entity. If there is one apex
element node in the fragment, it is serialized as an XML document.

So my counsel is to reflect in your text that the languages are creating
sequences of nodes to be serialized and that XML only happens if serialization
is engaged and is engaged requesting XML syntax.

I hope this is helpful.

At 2023-04-10 11:42 +0000, you wrote:
>Hi all,
>B  B While comparing the, data models of XPath
>1.0 and 3.1 languages (in the context of XSLT transformations), I
>noticed that, XSLT 3.0 doesn't have (i.e, it doesn't define) a data
>type named as "result tree fragment" Whereas, the data type "result
>tree fragment" is available with XSLT 1.0.
>
>With respect to this topic, I've been comparing the semantics of XSLT
>xsl:variable instruction within 1.0 and 3.0 versions of XSLT language.
>
>1) From the XSLT 1.0 spec
>A variable is a name that may be bound to a value. The value to which a
>variable is bound (the value of the variable) can be an object of any
>of the types that can be returned by expressions.
>There is a region of the stylesheet tree within which the binding is
visible.
>
>Result Tree Fragments
>Variables introduce an additional data-type into the expression
>language. This additional data type is called result tree fragment. A
>variable may be bound to a result tree fragment instead of one of the
>four basic XPath data-types (string, number, boolean, node-set). A
>result tree fragment represents a fragment of the result tree.
>
>2) From the XSLT 3.0 spec
>The value of the variable is computed using the expression given in the
>select attribute or the contained sequence constructor.
>
>I think, from the point of view of XSLT language in general, "result
>tree fragment" (from XSLT
>1.0) and "sequence constructor" (from XSLT 3.0) both serialize into the
>XSLT transformation'sB output (which typically would be XML for this
>discussion). The XSLT 3.0 sequence constructor, shall result in a value
>with a XPath 3.1 data type item()+. The XSLT 3.0 language, defines
>"sequence constructor" as : A sequence constructor is a sequence of
>zero or more sibling nodes in the stylesheet that can be evaluated to
>return a sequence of nodes, atomic values, and function items.
>
>It seems to me that, XSLT 1.0's "result tree fragment" (before being
>serialized to the output
>XML) is a well-formed XML fragment. Whereas, XSLT 3.0's sequence
>constructor is also a well-formed XML fragment, that evaluates to a
>sequence of nodes, atomic values, and function items. Other than, the
>XPath 3.1 function items (which is not available with XSLT 1.0/XPath
>1.0), XSLT 3.0's sequence of nodes and atomic values looks to me, an
>intermediate compiler representation that is finally transformed into
>the XML document available as a result of XSLT transformation.
>
>Any thoughts about this topic, shall be useful to know.
>
>
>--
>Regards,
>Mukul Gandhi
><http://www.m/
>ulberrytech.com%2Fxsl%2Fxsl-list&data=05%7C01%7Cwendell.piez%40nist.gov
>%7C1ce2e17250af4317c44408db39bfab9d%7C2ab5d82fd8fa4797a93e054655c61dec%
>7C1%7C0%7C638167267620375948%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMD
>AiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=
>EjZuwTtbQO6lijG6J7RJ6jezudsWxUsgOcvuHB0LsaQ%3D&reserved=0>XSL-List info
>and archive
><http://lists/
>.mulberrytech.com%2Funsub%2Fxsl-list%2F96802&data=05%7C01%7Cwendell.pie
>z%40nist.gov%7C1ce2e17250af4317c44408db39bfab9d%7C2ab5d82fd8fa4797a93e0
>54655c61dec%7C1%7C0%7C638167267620375948%7CUnknown%7CTWFpbGZsb3d8eyJWIj
>oiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%
>7C%7C&sdata=5cClAQPJDVDjFoSXbrlyVg2ssT09YUKjDsdrl4B%2Bzqw%3D&reserved=0
>>EasyUnsubscribe
>(<>by email)


--
Contact info, blog, articles, etc. http://www.cranesoftwrights.com/s/ | Check
our site for free XML, XSLT, XSL-FO and UBL developer resources | Streaming
hands-on XSLT/XPath 2 training class @US$125 (5 hours free) | Essays (UBL,
XML, etc.) http://www.linkedin.com/today/author/gkholman |

Current Thread