Templating - sgml/signature GitHub Wiki

The W3 Word Processor Filters page should answer most of these questions. For more details, here some resources on the evolution of separating content from presentation:

Markup and typesetting languages are the earliest examples of templating. Here is the Wikipedia definition:

A markup language is a modern system for annotating a document in a way that is syntactically distinguishable from the text. The idea and terminology evolved from the "marking up" of manuscripts, i.e., the revision instructions by editors, traditionally written with a blue pencil on authors' manuscripts. Examples are typesetting instructions such as those found in troff and LaTeX, or structural markers such as XML tags.

Here is a diagram:

                        RUNOFF                      "Generic Coding"                 "Editorial Structure Tags"
                   (Jerome Saltzer, 1964)         (William Tunnicliffe, 1967)          (Stanley Rice, pre-1970)
                            |                               |                                     |
                            |                               |                                     |
        TeX          roff - nroff - troff                   |-------------------------------------|
 (Don Knuth, 1977)   (Josef Osanna, 1973)                   |
                                                           GML
                                                    (Charles Goldfarb, 1969)
                                                            |                       SCRIBE
                                                            |                   (Brian Reid, 1980)
                                                            |                          |
                                                            |--------------------------|
                                                          SGML
                                                      (Standard, 1980)
                                                     |                |
                                                     |                |
                                                   HTML              XML
                                            (Berners-Lee, 1990)    (Standard, 1998)

As far as web site templating, SSI is the mother of them all.

From a security standpoint, JSP scriptlets have vulnerabilities:

There are a handful of objects made available in JSPs which are susceptible to security flaws. Their corresponding Java class functions are used as is in scriptlets. All the same security rules should apply.

For example, one session variable:

 <%=session.getAttribute(name)%>

can taint another:

<% 
String name = request.getParameter("username");
session.setAttribute("taintedAttribute", name);
%>

and unescaped strings can be dangerous as well:

<style>
<%
  String parm = request.getParameter("foobar");
  String cssEscaped = Escape.cssString(parm);
%>

a[href *= "<%= cssEscaped %>"] {
   background-color: pink!important;
}
</style>

XSLT

XSLT uses a hierarchy to allow parameters to be redefined:

  • the with-param value has the highest precedence
  • the param value has the second highest precedence
  • the value-of value has the third highest precedence

For example:

<xsl:template match="/">
    <xsl:call-template name="blob">
        <xsl:with-param name="par" select="'some-value'"/>
    </xsl:call-template>
</xsl:template>

<xsl:template name="blob">
    <xsl:param name="par" select="'default-value'"/>
    <xsl:value-of select="$param"/>
</xsl:template>

Modes in XSLT allow us to invoke templates based on matching XPath selectors, which is a form of delegation:

<xsl:template match="/">
    <!-- Apply templateA -->
    <xsl:apply-templates mode="templateA"/>
</xsl:template>

<xsl:template match="someElement" mode="templateA">
    <!-- Your templateA logic here -->
</xsl:template>

UIML

UIML is an abstraction which can be used to generate XSLT, JSX, or any other tag based language easily using XSLT. Here is 'Hello World':

<uiml>
  <part class="HelloWorld">
    <content>
      <data>
        <![CDATA[Hello, World!]]>
      </data>
    </content>
  </part>
</uiml>

RFC 6570

Transclusion

Slots in web components vs XSLT transclusion

Slots in Web Components

 <my-component>
   <p slot="mySlot">Content to be transcluded</p>
 </my-component>

 <script>
   this.shadowRoot.addEventListener('slotchange', (event) => {
     const slotContent = event.target.assignedNodes();
     // Handle the slot content as needed
   });
</script>

XSLT

 <!-- doc1.xml -->
 <chapter>
   <title>doc1.xml</title>
   <p>First paragraph</p>
   <transclusion src="doc2.xml"/>
   <p>Last paragraph</p>
 </chapter>

 <!-- XSLT stylesheet -->
 <xsl:template match="transclusion">
   <xsl:copy-of select="document(@src)"/>
 </xsl:template>

MediaWiki

References

Property Accessors

XBL

CSS

⚠️ **GitHub.com Fallback** ⚠️