| 279 | This directive defines a ''match template'': given an XPath expression, it replaces any element in the template that matches the expression with its own content. |
| 280 | |
| 281 | For example, the match template defined in the following template matches any element with the tag name “greeting”: |
| 282 | |
| 283 | {{{ |
| 284 | #!xml |
| 285 | <div xmlns:py="http://markup.edgewall.org/"> |
| 286 | <span py:match="greeting"> |
| 287 | Hello ${select('@name')} |
| 288 | </span> |
| 289 | <greeting name="Dude" /> |
| 290 | </div> |
| 291 | }}} |
| 292 | |
| 293 | This would result in the following output: |
| 294 | |
| 295 | {{{ |
| 296 | #!xml |
| 297 | <div> |
| 298 | <span> |
| 299 | Hello Dude |
| 300 | </span> |
| 301 | </div> |
| 302 | }}} |
| 303 | |
| 304 | This directive can also be used as an element: |
| 305 | |
| 306 | {{{ |
| 307 | #!xml |
| 308 | <div xmlns:py="http://markup.edgewall.org/"> |
| 309 | <py:match path="greeting"> |
| 310 | <span>Hello ${select('@name')}</span> |
| 311 | </py:match> |
| 312 | <greeting name="Dude" /> |
| 313 | </div> |
| 314 | }}} |
| 315 | |