splitcells.net's XSL/XML Code Guidelines

These are the guidelines used for XSL code on this site. These represent part of my current understanding of XSL and may be incorrect.

Use attributes only in order state that its content should not be processed by templates. Use explicit elements in the other case. If it makes sense, attributes and values should be supported. If the distinction does not make sense, attributes should not be used or supported. An attribute and its equivalent should not both be present in the same element.

Templates should be applied as late as possible. Example: Inside a template an intermediate element is created and templates are applied to it. Such intermediate elements often contain child elements with additional information. if intermediate elements are created which can be adapted with elements from the inputs

    d:todo
    • Use intermediate XML document in order to support different types of XML documents for the layout.

Create for each namespace a template that terminates the execution with an error via xsl:message terminate="true" . This way incorrect elements can be detected without any XSD.

 Value-of extracts the value of the node that is queried by the select attribute. All elements that are children of the selected node are thereby striped.   Copy-of creates a copy of the queried node. In general copy-of should be used to generate XML nodes and value-of should be used to generate strings that are not XML nodes.

In order to output objects where all processing is already done, use a template that matches */text()[normalize-space()] . This template should not be called directly. Instead it should be applied implicitly via apply-templates . This ensures ensures that results does not contain any unprocessed values.

    d:todo
    • normalize-space($variable-name) != ''
    d:todo
    • normalize-space($variable-name) != ''

Whitespace is best rendered by the non breaking space entity 160 which works for HTML output.

Document that everything is subject, object or predicated. Everything else is just a library of these.

wide screen

These are the guidelines used for XSL code on this site. These represent part of my current understanding of XSL and may be incorrect.

  1.  Open Tasks 
    d:toDo
    • d:todo
      • Avoid using xml attributes and use them only if exact strings are required and no tempaltes should be applied to its value.
    • d:todo
      • Minimize abstract syntax tree complexity by avoiding using XML attributes.