217 lines
9.2 KiB
HTML
217 lines
9.2 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 Tree Fold (Guile Reference Manual)</title>
|
||
|
|
||
|
<meta name="description" content="SXML Tree Fold (Guile Reference Manual)">
|
||
|
<meta name="keywords" content="SXML Tree Fold (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="SXPath.html" rel="next" title="SXPath">
|
||
|
<link href="Transforming-SXML.html" rel="prev" title="Transforming SXML">
|
||
|
<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-Tree-Fold">
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="SXPath.html" accesskey="n" rel="next">SXPath</a>, Previous: <a href="Transforming-SXML.html" accesskey="p" rel="prev">Transforming SXML</a>, Up: <a href="SXML.html" accesskey="u" rel="up">SXML</a> [<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="SXML-Tree-Fold-1"><span>7.21.5 SXML Tree Fold<a class="copiable-link" href="#SXML-Tree-Fold-1"> ¶</a></span></h4>
|
||
|
<ul class="mini-toc">
|
||
|
<li><a href="#Overview-1" accesskey="1">Overview</a></li>
|
||
|
<li><a href="#Usage-2" accesskey="2">Usage</a></li>
|
||
|
</ul>
|
||
|
<div class="subsubsection-level-extent" id="Overview-1">
|
||
|
<h4 class="subsubsection"><span>7.21.5.1 Overview<a class="copiable-link" href="#Overview-1"> ¶</a></span></h4>
|
||
|
<p><code class="code">(sxml fold)</code> defines a number of variants of the <em class="dfn">fold</em>
|
||
|
algorithm for use in transforming SXML trees. Additionally it defines
|
||
|
the layout operator, <code class="code">fold-layout</code>, which might be described as a
|
||
|
context-passing variant of SSAX’s <code class="code">pre-post-order</code>.
|
||
|
</p>
|
||
|
</div>
|
||
|
<div class="subsubsection-level-extent" id="Usage-2">
|
||
|
<h4 class="subsubsection"><span>7.21.5.2 Usage<a class="copiable-link" href="#Usage-2"> ¶</a></span></h4>
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-foldt"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">foldt</strong> <var class="def-var-arguments">fup fhere tree</var><a class="copiable-link" href="#index-foldt"> ¶</a></span></dt>
|
||
|
<dd><p>The standard multithreaded tree fold.
|
||
|
</p>
|
||
|
<p><var class="var">fup</var> is of type [a] -> a. <var class="var">fhere</var> is of type object -> a.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-foldts-1"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">foldts</strong> <var class="def-var-arguments">fdown fup fhere seed tree</var><a class="copiable-link" href="#index-foldts-1"> ¶</a></span></dt>
|
||
|
<dd><p>The single-threaded tree fold originally defined in SSAX. See <a class="xref" href="SSAX.html">SSAX: A Functional XML Parsing Toolkit</a>,
|
||
|
for more information.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-foldts_002a"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">foldts*</strong> <var class="def-var-arguments">fdown fup fhere seed tree</var><a class="copiable-link" href="#index-foldts_002a"> ¶</a></span></dt>
|
||
|
<dd><p>A variant of <code class="code">foldts</code> that allows pre-order tree
|
||
|
rewrites. Originally defined in Andy Wingo’s 2007 paper,
|
||
|
<em class="emph">Applications of fold to XML transformation</em>.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-fold_002dvalues"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">fold-values</strong> <var class="def-var-arguments">proc list . seeds</var><a class="copiable-link" href="#index-fold_002dvalues"> ¶</a></span></dt>
|
||
|
<dd><p>A variant of <code class="code">fold</code> that allows multi-valued seeds. Note that the
|
||
|
order of the arguments differs from that of <code class="code">fold</code>. See <a class="xref" href="SRFI_002d1-Fold-and-Map.html">Fold, Unfold & Map</a>.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-foldts_002a_002dvalues"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">foldts*-values</strong> <var class="def-var-arguments">fdown fup fhere tree . seeds</var><a class="copiable-link" href="#index-foldts_002a_002dvalues"> ¶</a></span></dt>
|
||
|
<dd><p>A variant of <code class="code">foldts*</code> that allows multi-valued
|
||
|
seeds. Originally defined in Andy Wingo’s 2007 paper, <em class="emph">Applications
|
||
|
of fold to XML transformation</em>.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-fold_002dlayout"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">fold-layout</strong> <var class="def-var-arguments">tree bindings params layout stylesheet</var><a class="copiable-link" href="#index-fold_002dlayout"> ¶</a></span></dt>
|
||
|
<dd><p>A traversal combinator in the spirit of <code class="code">pre-post-order</code>.
|
||
|
See <a class="xref" href="Transforming-SXML.html">Transforming SXML</a>.
|
||
|
</p>
|
||
|
<p><code class="code">fold-layout</code> was originally presented in Andy Wingo’s 2007 paper,
|
||
|
<em class="emph">Applications of fold to XML transformation</em>.
|
||
|
</p>
|
||
|
<div class="example">
|
||
|
<pre class="example-preformatted">bindings := (<binding>...)
|
||
|
binding := (<tag> <handler-pair>...)
|
||
|
| (*default* . <post-handler>)
|
||
|
| (*text* . <text-handler>)
|
||
|
tag := <symbol>
|
||
|
handler-pair := (pre-layout . <pre-layout-handler>)
|
||
|
| (post . <post-handler>)
|
||
|
| (bindings . <bindings>)
|
||
|
| (pre . <pre-handler>)
|
||
|
| (macro . <macro-handler>)
|
||
|
</pre></div>
|
||
|
|
||
|
<dl class="table">
|
||
|
<dt><var class="var">pre-layout-handler</var></dt>
|
||
|
<dd><p>A function of three arguments:
|
||
|
</p>
|
||
|
<dl class="table">
|
||
|
<dt><var class="var">kids</var></dt>
|
||
|
<dd><p>the kids of the current node, before traversal
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><var class="var">params</var></dt>
|
||
|
<dd><p>the params of the current node
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><var class="var">layout</var></dt>
|
||
|
<dd><p>the layout coming into this node
|
||
|
</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
<p><var class="var">pre-layout-handler</var> is expected to use this information to return a
|
||
|
layout to pass to the kids. The default implementation returns the
|
||
|
layout given in the arguments.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><var class="var">post-handler</var></dt>
|
||
|
<dd><p>A function of five arguments:
|
||
|
</p>
|
||
|
<dl class="table">
|
||
|
<dt><var class="var">tag</var></dt>
|
||
|
<dd><p>the current tag being processed
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><var class="var">params</var></dt>
|
||
|
<dd><p>the params of the current node
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><var class="var">layout</var></dt>
|
||
|
<dd><p>the layout coming into the current node, before any kids were processed
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><var class="var">klayout</var></dt>
|
||
|
<dd><p>the layout after processing all of the children
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><var class="var">kids</var></dt>
|
||
|
<dd><p>the already-processed child nodes
|
||
|
</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
<p><var class="var">post-handler</var> should return two values, the layout to pass to the
|
||
|
next node and the final tree.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><var class="var">text-handler</var></dt>
|
||
|
<dd><p><var class="var">text-handler</var> is a function of three arguments:
|
||
|
</p>
|
||
|
<dl class="table">
|
||
|
<dt><var class="var">text</var></dt>
|
||
|
<dd><p>the string
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><var class="var">params</var></dt>
|
||
|
<dd><p>the current params
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><var class="var">layout</var></dt>
|
||
|
<dd><p>the current layout
|
||
|
</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
<p><var class="var">text-handler</var> should return two values, the layout to pass to the
|
||
|
next node and the value to which the string should transform.
|
||
|
</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
</dd></dl>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="SXPath.html">SXPath</a>, Previous: <a href="Transforming-SXML.html">Transforming SXML</a>, Up: <a href="SXML.html">SXML</a> [<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>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|