1
0
Fork 0
cl-sites/guile.html_node/sxml-apply_002dtemplates.html
2024-12-17 12:49:28 +01:00

103 lines
4.5 KiB
HTML

<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This manual documents Guile version 3.0.10.
Copyright (C) 1996-1997, 2000-2005, 2009-2023 Free Software Foundation,
Inc.
Copyright (C) 2021 Maxime Devos
Copyright (C) 2024 Tomas Volf
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
copy of the license is included in the section entitled "GNU Free
Documentation License." -->
<title>sxml apply-templates (Guile Reference Manual)</title>
<meta name="description" content="sxml apply-templates (Guile Reference Manual)">
<meta name="keywords" content="sxml apply-templates (Guile Reference Manual)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content=".texi2any-real">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="SXML.html" rel="up" title="SXML">
<link href="sxml-ssax-input_002dparse.html" rel="prev" title="sxml ssax input-parse">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>
<link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css">
</head>
<body lang="en">
<div class="subsection-level-extent" id="sxml-apply_002dtemplates">
<div class="nav-panel">
<p>
Previous: <a href="sxml-ssax-input_002dparse.html" accesskey="p" rel="prev">(sxml ssax input-parse)</a>, Up: <a href="SXML.html" accesskey="u" rel="up">SXML</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsection" id="g_t_0028sxml-apply_002dtemplates_0029"><span>7.21.8 (sxml apply-templates)<a class="copiable-link" href="#g_t_0028sxml-apply_002dtemplates_0029"> &para;</a></span></h4>
<ul class="mini-toc">
<li><a href="#Overview-4" accesskey="1">Overview</a></li>
<li><a href="#Usage-4" accesskey="2">Usage</a></li>
</ul>
<div class="subsubsection-level-extent" id="Overview-4">
<h4 class="subsubsection"><span>7.21.8.1 Overview<a class="copiable-link" href="#Overview-4"> &para;</a></span></h4>
<p>Pre-order traversal of a tree and creation of a new tree:
</p>
<div class="example smallexample">
<pre class="example-preformatted"> apply-templates:: tree x &lt;templates&gt; -&gt; &lt;new-tree&gt;
</pre></div>
<p>where
</p>
<div class="example smallexample">
<pre class="example-preformatted"> &lt;templates&gt; ::= (&lt;template&gt; ...)
&lt;template&gt; ::= (&lt;node-test&gt; &lt;node-test&gt; ... &lt;node-test&gt; . &lt;handler&gt;)
&lt;node-test&gt; ::= an argument to node-typeof? above
&lt;handler&gt; ::= &lt;tree&gt; -&gt; &lt;new-tree&gt;
</pre></div>
<p>This procedure does a <em class="emph">normal</em>, pre-order traversal of an SXML
tree. It walks the tree, checking at each node against the list of
matching templates.
</p>
<p>If the match is found (which must be unique, i.e., unambiguous), the
corresponding handler is invoked and given the current node as an
argument. The result from the handler, which must be a <code class="code">&lt;tree&gt;</code>,
takes place of the current node in the resulting tree. The name of the
function is not accidental: it resembles rather closely an
<code class="code">apply-templates</code> function of XSLT.
</p>
</div>
<div class="subsubsection-level-extent" id="Usage-4">
<h4 class="subsubsection"><span>7.21.8.2 Usage<a class="copiable-link" href="#Usage-4"> &para;</a></span></h4>
<dl class="first-deffn">
<dt class="deffn" id="index-apply_002dtemplates"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">apply-templates</strong> <var class="def-var-arguments">tree templates</var><a class="copiable-link" href="#index-apply_002dtemplates"> &para;</a></span></dt>
</dl>
</div>
</div>
</body>
</html>