1

regarding:

A literal result element acts as an instruction to construct an element node with the same name in the result tree. The XSLT processor effectively creates a shallow copy of the literal result element from the stylesheet and inserts it into the result tree at the location within the result tree that is currently being constructed.

Source: http://lenzconsulting.com/how-xslt-works/#literal_result_elements

I'm wondering what does he mean when he say The XSLT processor effectively creates a shallow copy of the literal result element ?

What's a shallow copy mean in this context?

Pacerier
  • 86,231
  • 106
  • 366
  • 634

1 Answers1

0

I'm wondering what does he mean when he sayThe XSLT processor effectively creates a shallow copy of the literal result element ?

What's a shallow copy mean in this context?

The W3C XSLT specification, which is the only normative document specification of the XSLT language doesn't use the term "shallow copy"

My guess what the material referenced in this question wanted to state, is illustrated by this example:

 <h1>
   <xsl:value-of select="."/>
 </h1>

In the output, the element <xsl:value-of select="."/> isn't copied. A "shallow copy" does not copy any children nodes.

Once again, it is best to forget about "shallow copying" of the literal redult element and to rely only on the normative specification.

Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431
  • @Java: The books by @Michael Kay are what I usually recommend -- he covers everything and in depth. – Dimitre Novatchev Jun 13 '11 at 04:28
  • @Dimitre ok give me an upvote.. i can't even post links or do upvotes until i've got 15 rep (that's really annoying). 15 rep is hard to get when you don't already have at least 15 rep – Pacerier Jun 13 '11 at 04:38
  • 1
    Actually the XSLT 2.0 spec does use the term "shallow copy", though only as a section heading, so there's no formal definition of the term. It means "create an element node whose name [and perhaps namespaces, base URI, etc] are the same as those of X, but without copying the children or attributes of X". – Michael Kay Jun 13 '11 at 08:45
  • @Michael Kay: Exactly, and saying that a literal-result-element is "shallow-copied" is plain wrong, because its attributes, if specified and not having AVTs -- are also copied. – Dimitre Novatchev Jun 13 '11 at 12:30