diff --git a/extensions/transformiix/docs/compiled-templates.html b/extensions/transformiix/docs/compiled-templates.html new file mode 100644 index 000000000000..27895591fd70 --- /dev/null +++ b/extensions/transformiix/docs/compiled-templates.html @@ -0,0 +1,100 @@ + + + + XSLT Templates and Compiling + + + +

XSLT Templates and Compiling

+

This document describes compiling of XSLT stylesheets and the + evaluation of the result.

+
+ +
+

Objectives:

+ +

Concepts:

+
+
+
LRE namespaces
+
The concept of namespaces needs two mappings of IDs to + prefix/namespaceURI pairs. We can't create LRE elements with + known LRE namespace URIs in the template, as namespace-alias can + be unknown. (In a sink, the namespace-alias element can occur + after the template element.) Therefore, LRE elements carry + localname and namespace ID and output tries to +
    +
  1. lookup the ID in the namespace alias list,
  2. +
  3. lookup the ID in the original namespace list.
  4. +
+ To identify aliases correctly, one namespace URI with two + prefixes needs two IDs.
+
+
+ +

Compilation:

+

The XSLT specification describes XSLT in terms of the XPath + datamodel, something pretty close to a DOM. So we talk about the + input in terms of DOM elements.

+
The DOM nodes in a stylesheet get compiled into either + + The xslInstructions fall into classes, +
    +
  1. simple instructions,
  2. +
  3. utilities (no-op, variable-pop, push-handler),
  4. +
  5. branching instructions,
  6. +
  7. instructions changing the result handler and
  8. +
  9. instructions calling into different + xslTopElements.
  10. +
+
+

How do instructions work?

+
The general pattern used to create output from a set of + instructions is +
while (instruction) {
+  rv = instruction.do(args);
+  if (NS_FAILED(rv)) {
+    //cleanup
+    return rv;
+  }
+  instruction = instruction.mNext;
+}
+ This says pretty much all about simple and utility instructions. +
+

Branching instructions

+
Branching instructions need a tad more work. A branching + instruction is a instruction that forks the flow of work. That + includes that instruction needs to be part of the + argument list of ::do().
+ Suggested scheme: Each possible path of workflow + starts with a no-op-instruction and ends with a link to + a single no-op-instruction. The do of the + branching instruction sets the instruction to a + no-op-instruction according to the decisions. The + iteration step in the main loop skips the no-op and the workflow + proceeds in the intented path. The trailing single no-op helps + in rejoining the paths, as that no-op can be created before the + paths and thus easily appended to each end of the paths.
+

Instructions that change the output handler

+
These instructions (attribute, comment, pi creating text + handlers, variable possibly creating a rtf handler) get created + by inserting a push-handler-instruction into the workflow for + the start of the element and the XSLT instruction at the + end. The handler instruction should keep a non-owning reference + to the push-handler-instruction to get the result and restore + the previous handler.
+ +