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

ti:key creates keys to be used with the same semantics as the XSLT ones. They can be created at any level in the template but their names must be unique.

XML source

<aaa>
     <bbb id="b1">pA</bbb>
     <bbb id="b2">pB</bbb>
     <bbb id="b3">pC</bbb>
     <bbb id="b4">pD</bbb>
     <ccc>b3</ccc>
     <ccc>b1</ccc>
     <ccc>b4</ccc>
     <ccc>b2</ccc>
</aaa>

Templatotron source

<xhtml xmlns="http://www.w3.org/1999/xhtml" xmlns:t="http://zvon.org/templatotron" xmlns:ti="http://zvon.org/templatotron/instruction" >
     <head>
          <title>AAA</title>
     </head>
     <body>
          <ti:key name="b-key" match="bbb" use="@id"/>
          <t:p t:select="//ccc" id="{key('b-key',.)}"/>
     </body>
</xhtml>
Output

<xhtml xmlns="http://www.w3.org/1999/xhtml" >
     <head>
          <title>AAA</title>
     </head>
     <body>
          <p id="pC">b3</p>
          <p id="pA">b1</p>
          <p id="pD">b4</p>
          <p id="pB">b2</p>
     </body>
</xhtml>