ZVON > > Templatotron
>> Page 2 << | Prev | Next | contents | introduction | reference | download |

Elements and attributes from the Templatotron namespace ("http://zvon.org/templatotron") adds functionality. The basic usage is shown in this example. Elements in final output are created from the template by following algorithm: take the local-name of the element from Templatotron namespace and create an element from a namespace of the nearest ancestor not from Templatotron namespace. Create this element for every node matched by t:select attribute with text contents taken from these nodes.

XML source

<aaa>
     <bbb>1</bbb>
     <bbb>3</bbb>
     <bbb>5</bbb>
     <ccc>11</ccc>
     <ccc>32</ccc>
     <ccc>53</ccc>
</aaa>

Templatotron source

<math xmlns="http://www.w3.org/1998/Math/MathML" xmlns:t="http://zvon.org/templatotron" >
     <apply>
          <plus/>
          <t:ci t:select="//bbb"/>
          <apply>
               <minus/>
               <t:ci t:select="//ccc"/>
          </apply>
     </apply>
</math>
Output

<math xmlns="http://www.w3.org/1998/Math/MathML" >
     <apply>
          <plus/>
          <ci>1</ci>
          <ci>3</ci>
          <ci>5</ci>
          <apply>
               <minus/>
               <ci>11</ci>
               <ci>32</ci>
               <ci>53</ci>
          </apply>
     </apply>
</math>