Rules for XSLT stylesheets

First step of processing an XML is the transformation with an exporter (this step is optional - source document nametree may be transported directly to coordinator if it accepts nametree's namespace). There are some conditions that must be met: (This applies to exporters aswell because each stylesheet acts as an exporter)

  • XSLT transforms elements from exactly one namespace. Elements can contain attributes from other namespaces though. The only other namespace that can occur in Source is the EuroMath namespace ("http://www.uniba.sk/euromath", from now reffered to as emp: prefix) elements and attributes.
  • It may produce XML with multiple namespaces. In such case the output document is split into the nametrees and handled separately by next exporters or a coordinator.
  • Elements in source XML may contain special attribute emp:id. This attribute with its value should be copied to every result element. If the transformation fails to do so, that part of document will be read-only in WYSIWYG editor. You may generate IDs for text nodes aswell, but only when XSLT processes the source document (please see the processingSource parameter).
  • Your XSLT must be able to process and produce emp:id attribute thus two or more XSLT transformers may be chained.
  • You may encounter emp:mark element in the source document. It marks the entrypoint to nametree with another namespace. This namespace is provided as text value of mark element. It also contains the emp:id of the entrypoint node in original document. Just copy it into the target document.
  • If strings are massively modified (string operations as concatenation, etc.) in the process of transformation, they should lose the emp:id attribute, rendering them read-only in the editor.
  • Exporter must not produce entity nodes. This does not apply for XSLT scripts: they are not able to do so.
  • If exporter is processing output of some other exporter rather than the source XML, it must not expect that all elements have IDs, and it must not create IDs for text nodes - they already were generated by first exporter in the exporter chain. However, if you need an ID of a text node (for example to create a reference to the node), you may use the following algorithm:

    Most commonly used method to transport the ID of a text is to enclose it in an element with its ID being set as the value of the emp:id attribute. Thus, if the text node's parent element's ID is synthetic then there is a high probability that it is the ID of text we are searching for.