Extensible modular markup/Scripting

From Wikiversity
Jump to navigation Jump to search

This page describes an XML namespace with the semantics of a Turing-complete template script language.

Our namespace is http://portonvictor.org/ns/script.

The language is an imperative programming language that is also a template language that is passes of XML markup of other namespaces unchanged. (So for example, the output of an XML document without this namespace will be the document itself unchanged.)

An example script:

<x xmlns:script="http://portonvictor.org/ns/script">
  <script:set name="a"><script:add><script:literal value="1"/><script:literal value="2"/></script:add></script:set>
  <script:if>
    <script:test><script:greater><script:var name="a"/><script:literal value="1.5"/></script:greater>
    <script:then>Show this text.</script:then>
  </script:if>
  <script:for name="b" from="1" to="10">
    <text>Counting... <script:var name="b"/></text>
  </script:for>
</x>