In computer science, transclusion is the inclusion of part or all of an electronic document into one or more other documents by hypertextreference. Transclusion is usually performed when the referencing document is displayed, and is normally automatic and transparent to the end user. The result of transclusion is a single integrated document made of parts assembled dynamically from separate sources, possibly stored on different computers in disparate places. Transclusion facilitates modular design: a resource is stored once and distributed for reuse in multiple documents. Updates or corrections to a resource are then reflected in any referencing documents. Ted Nelson coined the term for his 1980 nonlinear book Literary Machines, but the idea of master copy and occurrences was applied 17 years before, in Sketchpad.
Technical considerations
Context neutrality
Transclusion works better when transcluded sections of text are self-contained, so that the meaning and validity of the text is independent of context. For example, formulations like "as explained in the previous section" are problematic, because the transcluded section may appear in a different context, causing confusion. What constitutes "context neutral" text varies, but often includes things like company information or boilerplate.
Parameterization
Under some circumstances, and in some technical contexts, transcluded sections of text may not require strict adherence to the "context neutrality" principle, because the transcluded sections are capable of parameterization. Parameterization implies the ability to modify certain portions or subsections of a transcluded text depending on exogenous variables that can be changed independently. This is customarily done by supplying a transcluded text with one or more substitution placeholders. These placeholders are then replaced with the corresponding variable values prior to rendering the final transcluded output in context.
Origins
The concept of reusing file content began with computer programming languages: COBOL in 1960, followed by BCPL, PL/I, C, and by the 1990s, even FORTRAN. An include directive allows common source code to be reused while avoiding the pitfalls of Copy-and-paste-programming and hard coding of constants. As with many innovations, a problem developed. Multiple include directives may provide the same content as another include directive, inadvertently causing repetitions of the same source code into the final result, resulting in an error. Include guards help solve this by, after a single inclusion of content, thereafter omit the duplicate content. The idea of a single, reusable, source for information lead to concepts like: Don't repeat yourself and the abstraction principle. A further use was found to make programs more portable. Portable source code uses an include directive to specify a standard library, which contains system specific source code that varies with each computer environment.
Ted Nelson, who also originated the words "hypertext" and "hypermedia", coined the term "transclusion" in his 1980 book Literary Machines. Part of his proposal was the idea that micropayments could be automatically exacted from the reader for all the text, no matter how many snippets of content are taken from various places. However, according to Nelson, the concept of transclusion had already formed part of his 1965 description of hypertext. Nelson defines transclusion as, "...the same content knowably in more than one place," setting it apart from more special cases, such as the inclusion of content from a different location or an explicit quotation that remains connected to its origins,. Some hypertext systems, including Ted Nelson's own Xanadu Project, support transclusion. Nelson has delivered a demonstration of Web transclusion, the Little Transquoter. It creates a new format built on portion addresses from Web pages; when dereferenced, each portion on the resulting page remains click-connected to its original context.
, as a transmission protocol, has rudimentary support for transclusion via byte serving: specifying a byte range in an HTTP request message. Transclusion can occur either before or after transmission. For example:
An HTML document may be pre-composed by the server before delivery to the client using Server-Side Includes or another server-side application.
XML Entities or HTML Objects may be parsed by the client, which then requests the corresponding resources separately from the main document.
A web browser may cache elements using its own algorithms, which can operate without explicit directives in the document's markup.
AngularJS employs transclusion for nested directive operation.
Publishers of web content may object to the transclusion of material from their own web sites into other web sites, or they may require an agreement to do so. Critics of the practice may refer to various forms of inline linking as bandwidth theft or leeching. Other publishers may seek specifically to have their materials transcluded into other web sites, as in the form of web advertising, or as widgets like a hit counter or web bug. Mashups make use of transclusion to assemble resources or data into a new application, as by placing geo-tagged photos on an interactive map, or by displaying business metrics in an interactive dashboard.
Client-side HTML
defines elements for client-side transclusion of images, scripts, stylesheets, other documents, and other types of media. HTML has relied heavily on client-side transclusion from the earliest days of the Web, rather than embedding the raw data for such objects inline into a web page's markup. Through techniques such as Ajax, scripts associated with an HTML document can instruct a web browser to modify the document in-place, as opposed to the earlier technique of having to pull an entirely new version of the page from the web server. Such scripts may transclude elements or documents from a server after the web browser has rendered the page, in response to user input or changing conditions, for example. Future versions of HTML may support deeper transclusion of portions of documents using XML technologies such as entities, XPointer document referencing, and XSLT manipulations. XPointer is patented but is licensed under royalty-free terms. Proxy servers may employ transclusion to reduce redundant transmissions of commonly requested resources. A popular Front End Framework known as AngularJS developed and maintained by Google has a directive callend ng-transclude that marks the insertion point for the transcluded DOM of the nearest parent directive that uses transclusion.
Transclusion of source code into software design or reference materials lets source code be presented within the document, but not interpreted as part of the document, preserving the semantic consistency of the inserted code in relation to its source codebase.