summaryrefslogtreecommitdiffstats
path: root/src/boost/tools/boostbook/xsl/caramel
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/tools/boostbook/xsl/caramel
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/tools/boostbook/xsl/caramel')
-rw-r--r--src/boost/tools/boostbook/xsl/caramel/LICENSE58
-rw-r--r--src/boost/tools/boostbook/xsl/caramel/concept2docbook.xsl812
-rw-r--r--src/boost/tools/boostbook/xsl/caramel/cpp-operators.xml288
-rw-r--r--src/boost/tools/boostbook/xsl/caramel/unparser.xsl497
4 files changed, 1655 insertions, 0 deletions
diff --git a/src/boost/tools/boostbook/xsl/caramel/LICENSE b/src/boost/tools/boostbook/xsl/caramel/LICENSE
new file mode 100644
index 000000000..d26de04a0
--- /dev/null
+++ b/src/boost/tools/boostbook/xsl/caramel/LICENSE
@@ -0,0 +1,58 @@
+Software License, Version 1.0
+
+Copyright 2002-2003, Trustees of Indiana University.
+Copyright 2000-2001, University of Notre Dame.
+All rights reserved.
+
+Indiana University has the exclusive rights to license this product under the
+following license.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * All redistributions of source code must retain the above copyright notice,
+ the list of authors in the original source code, this list of conditions
+ and the disclaimer listed in this license;
+
+ * All redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the disclaimer listed in this license
+ in the documentation and/or other materials provided with the distribution;
+
+ * Any documentation included with all redistributions must include the
+ following acknowledgement:
+
+ "This product includes software developed at the University of Notre Dame
+ and the Pervasive Technology Labs at Indiana University. For technical
+ information contact Andrew Lumsdaine at the Pervasive Technology Labs at
+ Indiana University. For administrative and license questions contact the
+ Advanced Research and Technology Institute at 351 West 10th Street.
+ Indianapolis, Indiana 46202, phone 317-278-4100, fax 317-274-5902."
+
+ Alternatively, this acknowledgement may appear in the software itself, and
+ wherever such third-party acknowledgments normally appear.
+
+ * The name Indiana University, the University of Notre Dame or "Caramel"
+ shall not be used to endorse or promote products derived from this software
+ without prior written permission from Indiana University. For written
+ permission, please contact Indiana University Advanced Research &
+ Technology Institute.
+
+ * Products derived from this software may not be called "Caramel", nor may
+ Indiana University, the University of Notre Dame or "Caramel" appear in
+ their name, without prior written permission of Indiana University Advanced
+ Research & Technology Institute.
+
+Indiana University provides no reassurances that the source code provided does
+not infringe the patent or any other intellectual property rights of any other
+entity. Indiana University disclaims any liability to any recipient for claims
+brought by any other entity based on infringement of intellectual property
+rights or otherwise.
+
+LICENSEE UNDERSTANDS THAT SOFTWARE IS PROVIDED "AS IS" FOR WHICH NO WARRANTIES
+AS TO CAPABILITIES OR ACCURACY ARE MADE. INDIANA UNIVERSITY GIVES NO WARRANTIES
+AND MAKES NO REPRESENTATION THAT SOFTWARE IS FREE OF INFRINGEMENT OF THIRD
+PARTY PATENT, COPYRIGHT, OR OTHER PROPRIETARY RIGHTS. INDIANA UNIVERSITY MAKES
+NO WARRANTIES THAT SOFTWARE IS FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES",
+"TRAP DOORS", "WORMS", OR OTHER HARMFUL CODE. LICENSEE ASSUMES THE ENTIRE RISK
+AS TO THE PERFORMANCE OF SOFTWARE AND/OR ASSOCIATED MATERIALS, AND TO THE
+PERFORMANCE AND VALIDITY OF INFORMATION GENERATED USING SOFTWARE.
diff --git a/src/boost/tools/boostbook/xsl/caramel/concept2docbook.xsl b/src/boost/tools/boostbook/xsl/caramel/concept2docbook.xsl
new file mode 100644
index 000000000..655498066
--- /dev/null
+++ b/src/boost/tools/boostbook/xsl/caramel/concept2docbook.xsl
@@ -0,0 +1,812 @@
+<?xml version="1.0" ?>
+
+<!--
+Copyright (c) 2002-2003 The Trustees of Indiana University.
+ All rights reserved.
+Copyright (c) 2000-2001 University of Notre Dame. All rights reserved.
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:strip-space elements="* xsl:*"/>
+
+ <xsl:include href="unparser.xsl"/>
+
+ <xsl:key name="concepts" match="concept" use="@name"/>
+
+ <!-- The layout type to use for concept descriptions. Can be one of:
+ sgi: simulate the SGI STL documentation
+ austern: simulate the documentation in Generic Programming and the STL,
+ by Matthew H. Austern
+ caramel: simulate the formatting from Caramel
+ -->
+ <xsl:param name="boost.concept.layout" select="'austern'"/>
+
+ <xsl:template match="concept">
+ <refentry>
+ <xsl:attribute name="id">
+ <xsl:call-template name="generate.id"/>
+ </xsl:attribute>
+
+ <refmeta>
+ <refentrytitle>Concept <xsl:value-of select="@name"/></refentrytitle>
+ <manvolnum>7</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname><xsl:value-of select="@name"/></refname>
+ <xsl:if test="purpose">
+ <refpurpose>
+ <xsl:apply-templates select="purpose/*|purpose/text()"/>
+ </refpurpose>
+ </xsl:if>
+ </refnamediv>
+
+ <!--
+ <refentryinfo>
+ <xsl:for-each select="copyright | copyright-include | legalnotice">
+ <xsl:choose>
+ <xsl:when test="name(.)='copyright'">
+ <copyright><xsl:copy-of select="./node()"/></copyright>
+ </xsl:when>
+ <xsl:when test="name(.)='legalnotice'">
+ <legalnotice><xsl:copy-of select="./node()"/></legalnotice>
+ </xsl:when>
+ <xsl:when test="name(.)='copyright-include'">
+ <copyright><xsl:copy-of select="document(concat('../concepts/', @file))/copyright/node()"/></copyright>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:for-each>
+ </refentryinfo>
+-->
+
+ <xsl:if test="description">
+ <xsl:if test="description">
+ <refsect1>
+ <title>Description</title>
+ <xsl:for-each select="description">
+ <xsl:apply-templates/>
+ </xsl:for-each>
+ </refsect1>
+ </xsl:if>
+ </xsl:if>
+
+ <xsl:if test="refines | refines-when-mutable">
+ <refsect1>
+ <title>Refinement of</title>
+ <itemizedlist>
+ <xsl:if test="refines">
+ <xsl:for-each select="refines">
+ <listitem>
+ <para>
+ <xsl:call-template name="concept.link">
+ <xsl:with-param name="name" select="@concept"/>
+ </xsl:call-template>
+ </para>
+ </listitem>
+ </xsl:for-each>
+ </xsl:if>
+ <xsl:if test="refines-when-mutable">
+ <xsl:for-each select="refines-when-mutable">
+ <listitem>
+ <para>
+ <xsl:text>When mutable: </xsl:text>
+ <xsl:call-template name="concept.link">
+ <xsl:with-param name="name" select="@concept"/>
+ </xsl:call-template>
+ </para>
+ </listitem>
+ </xsl:for-each>
+ </xsl:if>
+ </itemizedlist>
+ </refsect1>
+ </xsl:if>
+
+ <!-- This part must be run even if there are no associated types to print out, so the hidden type definitions can be found -->
+ <xsl:variable name="definition_list">
+ <xsl:call-template name="make-definition-list">
+ <xsl:with-param name="typedefs" select="define-type | associated-type"/>
+ <xsl:with-param name="definition_list">
+ <xsl:for-each select="param/@name">
+ @(@<xsl:value-of select="."/>=<xsl:value-of select="."/>@)@
+ </xsl:for-each>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <!-- <xsl:message>Definition list: <xsl:value-of select="$definition_list"/></xsl:message> -->
+
+ <xsl:call-template name="print-associated-types">
+ <xsl:with-param name="typedefs" select="associated-type"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="concept.notation">
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ </xsl:call-template>
+
+ <xsl:variable name="notations">
+ <xsl:for-each select="notation">
+ @@(@@<xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="*[1]"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="ignore-cv" select="true()"/>
+ <xsl:with-param name="ignore-references" select="true()"/>
+ </xsl:call-template>@@=@@<xsl:value-of select="normalize-space(@variables)"/>@@)@@
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- <xsl:message>Notations: <xsl:value-of select="normalize-space($notations)"/> End notations</xsl:message> -->
+
+ <xsl:if test="definition">
+ <refsect1>
+ <title>Definitions</title>
+ <xsl:for-each select="definition">
+ <p><xsl:apply-templates/></p>
+ </xsl:for-each>
+ </refsect1>
+ </xsl:if>
+
+ <xsl:if test="valid-type-expression | models | models-when-mutable">
+ <refsect1>
+ <title>Type expressions</title>
+ <variablelist>
+ <xsl:for-each select="models">
+ <varlistentry>
+ <term/>
+ <listitem>
+ <para>
+ <xsl:call-template name="unparse-operator-definition">
+ <xsl:with-param name="typeref" select="."/>
+ <xsl:with-param name="operator_nodeset" select="key('concepts', @concept)/models-sentence/node()"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="notations" select="$notations"/>
+ <xsl:with-param name="ignore-cv" select="false()"/>
+ <xsl:with-param name="self" select="@concept"/>
+ <xsl:with-param name="use-code-block" select="true()"/>
+ </xsl:call-template>
+ </para>
+ </listitem>
+ </varlistentry>
+ </xsl:for-each>
+ <xsl:for-each select="models-when-mutable">
+ <varlistentry>
+ <term>Only when mutable</term>
+ <listitem>
+ <para>
+ <xsl:call-template name="unparse-operator-definition">
+ <xsl:with-param name="typeref" select="."/>
+ <xsl:with-param name="operator_nodeset" select="key('concepts', @concept)/models-sentence/node()"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="notations" select="$notations"/>
+ <xsl:with-param name="ignore-cv" select="false()"/>
+ <xsl:with-param name="self" select="@concept"/>
+ <xsl:with-param name="use-code-block" select="true()"/>
+ </xsl:call-template>
+ </para>
+ </listitem>
+ </varlistentry>
+ </xsl:for-each>
+ <xsl:for-each select="valid-type-expression">
+ <varlistentry>
+ <term><xsl:value-of select="@name"/></term>
+ <listitem>
+ <para>
+ <type>
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="*[2]"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="notations" select="normalize-space($notations)"/>
+ </xsl:call-template>
+ </type>
+
+ <xsl:comment/> must be
+ <xsl:for-each select="return-type/*">
+ <xsl:if test="position()!=1 and last()!=2">, </xsl:if>
+ <xsl:if test="position()=last() and last()!=1"> and </xsl:if>
+ <xsl:call-template name="unparse-constraint">
+ <xsl:with-param name="constraint" select="."/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="type-expr-mode" select="true()"/>
+ </xsl:call-template>
+ </xsl:for-each><xsl:comment/>.
+ </para>
+
+ <xsl:if test="description">
+ <xsl:for-each select="description">
+ <xsl:apply-templates/>
+ </xsl:for-each>
+ </xsl:if>
+ </listitem>
+ </varlistentry>
+ </xsl:for-each>
+ </variablelist>
+ </refsect1>
+ </xsl:if>
+
+ <xsl:if test="valid-expression">
+ <refsect1>
+ <title>Valid expressions</title>
+
+ <xsl:variable name="columns">
+ <xsl:if test="valid-expression/return-type">
+ <xsl:text>T</xsl:text>
+ </xsl:if>
+ <xsl:if test="valid-expression/precondition">
+ <xsl:text>P</xsl:text>
+ </xsl:if>
+ <xsl:if test="valid-expression/semantics">
+ <xsl:text>S</xsl:text>
+ </xsl:if>
+ <xsl:if test="valid-expression/postcondition">
+ <xsl:text>O</xsl:text>
+ </xsl:if>
+ </xsl:variable>
+
+ <informaltable>
+ <tgroup>
+ <xsl:attribute name="cols">
+ <xsl:value-of select="string-length($columns) + 2"/>
+ </xsl:attribute>
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Expression</entry>
+ <xsl:if test="contains($columns, 'T')">
+ <entry>Type</entry>
+ </xsl:if>
+ <xsl:if test="contains($columns, 'P')">
+ <entry>Precondition</entry>
+ </xsl:if>
+ <xsl:if test="contains($columns, 'S')">
+ <entry>Semantics</entry>
+ </xsl:if>
+ <xsl:if test="contains($columns, 'O')">
+ <entry>Postcondition</entry>
+ </xsl:if>
+ </row>
+ </thead>
+ <tbody>
+ <xsl:apply-templates select="valid-expression">
+ <xsl:with-param name="definition_list"
+ select="$definition_list"/>
+ <xsl:with-param name="notations"
+ select="normalize-space($notations)"/>
+ <xsl:with-param name="columns" select="$columns"/>
+ </xsl:apply-templates>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <!-- Doug prefers the table
+ <variablelist>
+ <xsl:for-each select="valid-expression">
+ <xsl:variable name="as-cxx-value">
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="*[1]"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="notations" select="normalize-space($notations)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <varlistentry>
+ <term><xsl:value-of select="@name"/>: <literal><xsl:value-of select="$as-cxx-value"/></literal></term>
+ <listitem><variablelist>
+ <xsl:if test="return-type/*">
+ <varlistentry><term>Return value</term><listitem><para>
+ <xsl:for-each select="return-type/*">
+ <xsl:if test="position()!=1 and last()!=2">, </xsl:if>
+ <xsl:if test="position()=last() and last()!=1"> and </xsl:if>
+ <xsl:call-template name="unparse-constraint">
+ <xsl:with-param name="constraint" select="."/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="capitalize" select="position()=1"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </para></listitem></varlistentry>
+ </xsl:if>
+
+ <xsl:for-each select="precondition">
+ <varlistentry><term>Precondition</term><listitem><para>
+ <xsl:apply-templates/>
+ </para></listitem></varlistentry>
+ </xsl:for-each>
+
+ <xsl:for-each select="semantics">
+ <varlistentry><term>Semantics</term><listitem><para>
+ <xsl:apply-templates/>
+ </para></listitem></varlistentry>
+ </xsl:for-each>
+
+ <xsl:for-each select="postcondition">
+ <varlistentry><term>Postcondition</term><listitem><para>
+ <xsl:apply-templates/>
+ </para></listitem></varlistentry>
+ </xsl:for-each>
+
+ </variablelist></listitem>
+ </varlistentry>
+
+ </xsl:for-each>
+ </variablelist>
+-->
+ </refsect1>
+ </xsl:if>
+
+ <xsl:if test="complexity">
+ <refsect1>
+ <title>Complexity</title>
+ <xsl:for-each select="complexity">
+ <para><xsl:apply-templates/></para>
+ </xsl:for-each>
+ </refsect1>
+ </xsl:if>
+
+ <xsl:if test="invariant">
+ <refsect1>
+ <title>Invariants</title>
+ <variablelist>
+ <xsl:for-each select="invariant">
+ <varlistentry>
+ <term><xsl:value-of select="@name"/></term>
+ <listitem>
+ <para><xsl:apply-templates/></para>
+ </listitem>
+ </varlistentry>
+ </xsl:for-each>
+ </variablelist>
+ </refsect1>
+ </xsl:if>
+
+ <xsl:if test="example-model">
+ <refsect1>
+ <title>Models</title>
+ <itemizedlist>
+ <xsl:for-each select="example-model">
+ <listitem>
+ <simplelist type="inline">
+ <xsl:for-each select="*">
+ <xsl:variable name="example-value">
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="."/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <member><type><xsl:value-of select="$example-value"/></type></member>
+ </xsl:for-each>
+ </simplelist>
+ </listitem>
+ </xsl:for-each>
+ </itemizedlist>
+ </refsect1>
+ </xsl:if>
+
+ <xsl:variable name="see-also-list-0" select="concept-ref | see-also | refines | refines-when-mutable | models-as-first-arg | models | models-when-mutable"/>
+ <xsl:variable name="see-also-list-1" select="$see-also-list-0[string(@name | @concept) != string(../@name)]"/>
+ <xsl:variable name="see-also-list" select="$see-also-list-1[not(string(@name|@concept) = (preceding::*/@name | preceding::*/@concept | ancestor::*/@name | ancestor::*/@concept))]"/>
+ <xsl:if test="$see-also-list">
+ <refsect1>
+ <title>See also</title>
+ <itemizedlist>
+ <xsl:for-each select="$see-also-list">
+ <xsl:sort select="string(@name|@concept)" data-type="text"/>
+ <listitem>
+ <para>
+ <xsl:call-template name="concept.link">
+ <xsl:with-param name="name" select="@name|@concept"/>
+ </xsl:call-template>
+ </para>
+ </listitem>
+ </xsl:for-each>
+ </itemizedlist>
+ </refsect1>
+ </xsl:if>
+
+ </refentry>
+ </xsl:template>
+
+ <xsl:template name="unparse-constraint">
+ <xsl:param name="constraint"/>
+ <xsl:param name="definition_list"/>
+ <xsl:param name="type-expr-mode" select="false()"/>
+ <xsl:param name="capitalize" select="true()"/>
+
+ <xsl:choose>
+
+ <xsl:when test="name($constraint)='require-same-type'">
+ <xsl:if test="$type-expr-mode">identical to </xsl:if>
+ <type>
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="$constraint/*[1]"/>
+ <xsl:with-param name="definition_list" select="definition_list"/>
+ </xsl:call-template>
+ </type>
+ </xsl:when>
+
+ <xsl:when test="name($constraint)='convertible-to'">
+ <xsl:choose>
+ <xsl:when test="$type-expr-mode">convertible to </xsl:when>
+ <xsl:when test="not($type-expr-mode) and $capitalize">Convertible to </xsl:when>
+ <xsl:when test="not($type-expr-mode) and not($capitalize)">convertible to </xsl:when>
+ </xsl:choose>
+ <type>
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="$constraint/*[1]"/>
+ <xsl:with-param name="definition_list" select="definition_list"/>
+ </xsl:call-template>
+ </type>
+ </xsl:when>
+
+ <xsl:when test="name($constraint)='derived-from'">
+ <xsl:choose>
+ <xsl:when test="$type-expr-mode">derived from </xsl:when>
+ <xsl:when test="not($type-expr-mode) and $capitalize">Derived from </xsl:when>
+ <xsl:when test="not($type-expr-mode) and not($capitalize)">derived from </xsl:when>
+ </xsl:choose>
+ <type>
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="$constraint/*[1]"/>
+ <xsl:with-param name="definition_list" select="definition_list"/>
+ </xsl:call-template>
+ </type>
+ </xsl:when>
+
+ <xsl:when test="name($constraint)='assignable-to'">
+ <xsl:choose>
+ <xsl:when test="$type-expr-mode">assignable to </xsl:when>
+ <xsl:when test="not($type-expr-mode) and $capitalize">Assignable to </xsl:when>
+ <xsl:when test="not($type-expr-mode) and not($capitalize)">assignable to </xsl:when>
+ </xsl:choose>
+ <type>
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="$constraint/*[1]"/>
+ <xsl:with-param name="definition_list" select="definition_list"/>
+ </xsl:call-template>
+ </type>
+ </xsl:when>
+
+ <xsl:when test="name($constraint)='models-as-first-arg'">
+ <xsl:choose>
+ <xsl:when test="$type-expr-mode"> a model </xsl:when>
+ <xsl:when test="not($type-expr-mode) and $capitalize"> Models </xsl:when>
+ <xsl:when test="not($type-expr-mode) and not($capitalize)"> models </xsl:when>
+ </xsl:choose>
+ <xsl:if test="$constraint/*"><xsl:comment/>
+ (along with <xsl:for-each select="$constraint/*"><type>
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="."/>
+ <xsl:with-param name="definition_list" select="definition_list"/>
+ </xsl:call-template>
+ </type>
+ <xsl:choose>
+ <xsl:when test="position()=last()"/>
+ <xsl:when test="position()=last()-1 and last()=2"> and </xsl:when>
+ <xsl:when test="position()=last()-1 and last()!=2">, and </xsl:when>
+ <xsl:otherwise>, </xsl:otherwise>
+ </xsl:choose><xsl:comment/>
+ </xsl:for-each><xsl:comment/>) <xsl:comment/>
+ </xsl:if><xsl:comment/>
+ <xsl:if test="$type-expr-mode"> of </xsl:if>
+ <xsl:call-template name="concept.link">
+ <xsl:with-param name="name" select="$constraint/@concept"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="make-definition-list">
+ <xsl:param name="typedefs"/>
+ <xsl:param name="definition_list"/>
+
+ <xsl:choose>
+ <xsl:when test="$typedefs">
+ <xsl:variable name="type_definition">
+ <xsl:if test="name($typedefs[1]/*[1])!='description'">
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="$typedefs[1]/*[1]"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+
+ <xsl:variable name="new_type_definition">
+ <xsl:choose>
+ <xsl:when test="name($typedefs[1])='associated-type'">
+ <xsl:value-of select="$typedefs[1]/@name"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$type_definition"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:call-template name="make-definition-list">
+ <xsl:with-param name="typedefs" select="$typedefs[position()!=1]"/>
+ <xsl:with-param name="definition_list" select="concat($definition_list, ' @(@', $typedefs[1]/@name, '=', $new_type_definition, '@)@')"/>
+ </xsl:call-template>
+
+ </xsl:when>
+
+ <xsl:otherwise> <!-- End of expression list, emit the results that have accumulated -->
+ <xsl:value-of select="$definition_list"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="print-associated-types">
+ <xsl:param name="typedefs"/>
+ <xsl:param name="definition_list"/>
+
+ <xsl:if test="$typedefs">
+ <refsect1>
+ <title>Associated types</title>
+
+ <xsl:choose>
+ <xsl:when test="$boost.concept.layout='sgi'">
+ <informaltable>
+ <tgroup cols="2">
+ <tbody>
+ <xsl:apply-templates select="associated-type" mode="sgi">
+ <xsl:with-param name="definition_list"
+ select="$definition_list"/>
+ </xsl:apply-templates>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </xsl:when>
+ <xsl:when test="$boost.concept.layout='austern'">
+ <itemizedlist>
+ <xsl:apply-templates select="associated-type" mode="austern">
+ <xsl:with-param name="definition_list"
+ select="$definition_list"/>
+ </xsl:apply-templates>
+ </itemizedlist>
+ </xsl:when>
+ <xsl:when test="$boost.concept.layout='caramel'">
+ <segmentedlist>
+ <segtitle>Name</segtitle>
+ <segtitle>Code</segtitle>
+ <segtitle>Description</segtitle>
+ <xsl:for-each select="$typedefs">
+ <xsl:variable name="type_definition">
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="*[1]"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <seglistitem>
+ <seg><xsl:value-of select="@name"/></seg>
+ <seg><xsl:value-of select="$type_definition"/></seg>
+ <seg>
+ <xsl:for-each select="description">
+ <xsl:call-template name="description"/>
+ </xsl:for-each>
+ </seg>
+ </seglistitem>
+ </xsl:for-each>
+ </segmentedlist>
+ </xsl:when>
+ </xsl:choose>
+ </refsect1>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="comma-list">
+ <xsl:param name="list"/>
+
+ <xsl:if test="$list!=''">
+ <term><varname>
+ <xsl:if test="substring-before($list,' ')=''"><xsl:value-of select="$list"/></xsl:if>
+ <xsl:value-of select="substring-before($list,' ')"/>
+ </varname></term>
+ <xsl:call-template name="comma-list">
+ <xsl:with-param name="list" select="substring-after($list,' ')"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="associated-type" mode="sgi">
+ <row>
+ <entry><simpara><xsl:value-of select="@name"/></simpara></entry>
+
+ <entry>
+ <para>
+ <xsl:for-each select="description">
+ <xsl:apply-templates/>
+ </xsl:for-each>
+ </para>
+ </entry>
+ </row>
+ </xsl:template>
+
+ <xsl:template match="associated-type" mode="austern">
+ <xsl:param name="definition_list" select="''"/>
+
+ <listitem>
+ <para>
+ <emphasis role="bold"><xsl:value-of select="@name"/></emphasis>
+
+ <xsl:call-template name="preformatted">
+ <xsl:with-param name="text">
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="*[1]"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ </xsl:call-template>
+
+ <xsl:for-each select="description">
+ <xsl:apply-templates/>
+ </xsl:for-each>
+ </para>
+ </listitem>
+ </xsl:template>
+
+ <xsl:template match="valid-expression">
+ <xsl:param name="definition_list"/>
+ <xsl:param name="notations"/>
+ <xsl:param name="columns"/>
+
+ <row>
+ <entry><simpara><xsl:value-of select="@name"/></simpara></entry>
+
+ <entry>
+ <simpara>
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="*[1]"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="notations" select="$notations"/>
+ </xsl:call-template>
+ </simpara>
+ </entry>
+
+ <xsl:if test="contains($columns, 'T')">
+ <entry>
+ <simpara>
+ <xsl:for-each select="return-type/*">
+ <xsl:if test="position()!=1 and last()!=2">, </xsl:if>
+ <xsl:if test="position()=last() and last()!=1"> and </xsl:if>
+ <xsl:call-template name="unparse-constraint">
+ <xsl:with-param name="constraint" select="."/>
+ <xsl:with-param name="definition_list"
+ select="$definition_list"/>
+ <xsl:with-param name="capitalize" select="position()=1"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </simpara>
+ </entry>
+ </xsl:if>
+
+ <xsl:if test="contains($columns, 'P')">
+ <entry>
+ <xsl:for-each select="precondition">
+ <simpara><xsl:apply-templates/></simpara>
+ </xsl:for-each>
+ </entry>
+ </xsl:if>
+
+ <xsl:if test="contains($columns, 'S')">
+ <entry>
+ <xsl:for-each select="semantics">
+ <simpara><xsl:apply-templates/></simpara>
+ </xsl:for-each>
+ </entry>
+ </xsl:if>
+
+ <xsl:if test="contains($columns, 'O')">
+ <entry>
+ <xsl:for-each select="postcondition">
+ <simpara><xsl:apply-templates/></simpara>
+ </xsl:for-each>
+ </entry>
+ </xsl:if>
+ </row>
+ </xsl:template>
+
+ <xsl:template name="concept.notation">
+ <xsl:param name="definition_list"/>
+
+ <refsect1>
+ <title>Notation</title>
+ <variablelist>
+ <xsl:for-each select="param">
+ <varlistentry>
+ <term><xsl:value-of select="@name"/></term>
+ <listitem>
+ <simpara>
+ <xsl:text>A type playing the role of </xsl:text>
+ <xsl:value-of select="@role"/>
+ <xsl:text> in the </xsl:text>
+ <xsl:call-template name="concept.link">
+ <xsl:with-param name="name" select="../@name"/>
+ </xsl:call-template>
+ <xsl:text> concept.</xsl:text>
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </xsl:for-each>
+ <xsl:for-each select="notation">
+ <xsl:variable name="notation_name">
+ <xsl:call-template name="comma-list">
+ <xsl:with-param name="list"
+ select="normalize-space(@variables)"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <varlistentry>
+ <xsl:copy-of select="$notation_name"/>
+ <listitem>
+ <simpara>
+ <xsl:variable name="output-plural" select="substring-before(normalize-space(@variables),' ')!=''"/>
+ <xsl:if test="name(*[1])='sample-value'">Object<xsl:if test="$output-plural">s</xsl:if> of type </xsl:if>
+ <xsl:variable name="typeref-to-print" select="*[name()!='sample-value'] | sample-value/*[name()!='sample-value']"/>
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="$typeref-to-print"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="ignore-cv" select="true()"/>
+ <xsl:with-param name="ignore-references" select="true()"/>
+ </xsl:call-template>
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </xsl:for-each>
+ </variablelist>
+ </refsect1>
+ </xsl:template>
+
+ <xsl:template name="concept.link">
+ <xsl:param name="name" select="text()"/>
+ <xsl:param name="warn" select="true()"/>
+ <xsl:param name="text" select="$name"/>
+ <xsl:variable name="node" select="key('concepts', $name)"/>
+
+ <xsl:choose>
+ <xsl:when test="count($node)=0">
+ <xsl:if test="$warn">
+ <xsl:message>
+ <xsl:text>warning: cannot find concept '</xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>'</xsl:text>
+ </xsl:message>
+ </xsl:if>
+ <xsl:value-of select="$text"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="internal-link">
+ <xsl:with-param name="to">
+ <xsl:call-template name="generate.id">
+ <xsl:with-param name="node" select="$node"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ <xsl:with-param name="text" select="$text"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="remove-whitespace">
+ <xsl:param name="text" select="text()"/>
+
+ <xsl:variable name="normalized" select="normalize-space($text)"/>
+ <xsl:choose>
+ <xsl:when test="contains($normalized, ' ')">
+ <xsl:value-of select="substring-before($normalized, ' ')"/>
+ <xsl:call-template name="remove-whitespace">
+ <xsl:with-param name="text"
+ select="substring-after($normalized, ' ')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$normalized"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="concept" mode="generate.id">
+ <xsl:call-template name="remove-whitespace">
+ <xsl:with-param name="text" select="@name"/>
+ </xsl:call-template>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/src/boost/tools/boostbook/xsl/caramel/cpp-operators.xml b/src/boost/tools/boostbook/xsl/caramel/cpp-operators.xml
new file mode 100644
index 000000000..68626acbb
--- /dev/null
+++ b/src/boost/tools/boostbook/xsl/caramel/cpp-operators.xml
@@ -0,0 +1,288 @@
+<?xml version="1.0" ?>
+
+<!--
+Copyright (c) 2002-2003 The Trustees of Indiana University.
+ All rights reserved.
+Copyright (c) 2000-2001 University of Notre Dame. All rights reserved.
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt) -->
+
+<operator-list>
+ <!-- This list is from Pohl's book, and needs to be checked for accuracy -->
+
+ <op name="postincrement">
+ <apply priority="100"><arg num="1"/>++</apply> <!-- No assoc - always use parentheses -->
+ <impl position="method">operator++(int)</impl>
+ </op>
+
+ <op name="postdecrement">
+ <apply priority="100"><arg num="1"/>--</apply>
+ <impl position="method">operator--(int)</impl>
+ </op>
+
+ <op name="apply-function">
+ <apply priority="100"><name/>(<arg-list start="1" priority="30"/>)</apply>
+ <impl position="freestanding"><name/>(<arg-list/>)</impl>
+ </op>
+
+ <op name="apply-method">
+ <apply priority="100" assoc="1"><arg num="1"/>.<name/>(<arg-list start="2" priority="30"/>)</apply>
+ <impl position="method"><name/>(<arg-list/>)</impl>
+ </op>
+
+ <op name="pointer-apply-method">
+ <apply priority="100" assoc="1"><arg num="1"/>-&gt;<name/>(<arg-list start="2" priority="30"/>)</apply>
+ <impl>Error</impl>
+ </op>
+
+ <op name="apply-funcobj">
+ <apply priority="100" assoc="1"><arg num="1"/>(<arg-list start="2" priority="30"/>)</apply>
+ <impl position="method">operator()(<arg-list/>)</impl>
+ </op>
+
+ <op name="construct">
+ <apply priority="100"><arg num="1"/>(<arg-list start="2" priority="30"/>)</apply>
+ <impl position="method"><self/>(<arg-list/>)</impl>
+ </op>
+
+ <op name="subscript">
+ <apply priority="100" assoc="1"><arg num="1"/>[<arg num="2" priority="0"/>]</apply>
+ <impl position="method">operator[](<arg-list/>)</impl>
+ </op>
+
+ <op name="class-member">
+ <apply priority="100" assoc="1"><arg num="1"/>.<name/></apply>
+ <impl>Error</impl>
+ </op>
+
+ <op name="pointer-member">
+ <!-- Note: non-testable constraint -->
+ <apply priority="100"><arg num="1" assoc="1"/>-&gt;{member-name} (return type is pointer-to-object type)</apply>
+ <impl>operator-&gt;(<arg-list/>)</impl>
+ </op>
+
+ <op name="preincrement">
+ <apply priority="95">++<arg num="1"/></apply>
+ <impl position="method">operator++(<arg-list/>)</impl>
+ </op>
+
+ <op name="predecrement">
+ <apply priority="95">--<arg num="1"/></apply>
+ <impl position="method">operator--(<arg-list/>)</impl>
+ </op>
+
+ <op name="logical-not">
+ <apply priority="95" assoc="1">!<arg num="1"/></apply>
+ <impl position="method">operator!(<arg-list/>)</impl>
+ </op>
+
+ <op name="bitwise-not">
+ <apply priority="95" assoc="1">~<arg num="1"/></apply>
+ <impl position="method">operator~(<arg-list/>)</impl>
+ </op>
+
+ <op name="address-of">
+ <apply priority="95">&amp;<arg num="1"/></apply>
+ <impl position="method">operator&amp;(<arg-list/>)</impl>
+ </op>
+
+ <op name="dereference">
+ <apply priority="95" assoc="1">*<arg num="1"/></apply>
+ <impl position="method">operator*(<arg-list/>)</impl>
+ </op>
+
+ <op name="unary-plus">
+ <apply priority="95">+<arg num="1"/></apply>
+ <impl position="method">operator+(<arg-list/>)</impl>
+ </op>
+
+ <op name="unary-minus">
+ <apply priority="95">-<arg num="1"/></apply>
+ <impl position="method">operator-(<arg-list/>)</impl>
+ </op>
+
+ <op name="class-member-ptr">
+ <apply priority="90" assoc="1"><arg num="1"/>.*<arg num="2"/></apply>
+ <impl>Error</impl>
+ </op>
+
+ <op name="pointer-member-ptr">
+ <apply priority="90" assoc="1"><arg num="1"/>-&gt;*<arg num="2"/></apply>
+ <impl position="method">operator-&gt;*(<arg-list/>)</impl>
+ </op>
+
+ <op name="multiply">
+ <apply priority="90" assoc="1"><arg num="1"/> * <arg num="2"/></apply>
+ <impl position="freestanding">operator * (<arg-list/>)</impl>
+ </op>
+
+ <op name="divide">
+ <apply priority="90" assoc="1"><arg num="1"/> / <arg num="2"/></apply>
+ <impl position="freestanding">operator / (<arg-list/>)</impl>
+ </op>
+
+ <op name="modulus">
+ <apply priority="90" assoc="1"><arg num="1"/> % <arg num="2"/></apply>
+ <impl position="freestanding">operator % (<arg-list/>)</impl>
+ </op>
+
+ <op name="add">
+ <apply priority="85" assoc="1"><arg num="1"/> + <arg num="2"/></apply>
+ <impl position="freestanding">operator + (<arg-list/>)</impl>
+ </op>
+
+ <op name="subtract">
+ <apply priority="85" assoc="1"><arg num="1"/> - <arg num="2"/></apply>
+ <impl position="freestanding">operator - (<arg-list/>)</impl>
+ </op>
+
+ <op name="shift-left">
+ <apply priority="80" assoc="1"><arg num="1"/> &lt;&lt; <arg num="2"/></apply>
+ <impl position="freestanding">operator &lt;&lt; (<arg-list/>)</impl>
+ </op>
+
+ <op name="shift-right">
+ <apply priority="80" assoc="1"><arg num="1"/> &gt;&gt; <arg num="2"/></apply>
+ <impl position="freestanding">operator &gt;&gt; (<arg-list/>)</impl>
+ </op>
+
+ <op name="less-than">
+ <apply priority="75"><arg num="1"/> &lt; <arg num="2"/></apply>
+ <impl position="freestanding">operator &lt; (<arg-list/>)</impl>
+ </op>
+
+ <op name="greater-than">
+ <apply priority="75"><arg num="1"/> &gt; <arg num="2"/></apply>
+ <impl position="freestanding">operator &gt; (<arg-list/>)</impl>
+ </op>
+
+ <op name="less-than-or-equal">
+ <apply priority="75"><arg num="1"/> &lt;= <arg num="2"/></apply>
+ <impl position="freestanding">operator &lt;= (<arg-list/>)</impl>
+ </op>
+
+ <op name="greater-than-or-equal">
+ <apply priority="75"><arg num="1"/> &gt;= <arg num="2"/></apply>
+ <impl position="freestanding">operator &gt;= (<arg-list/>)</impl>
+ </op>
+
+ <op name="equal-to">
+ <apply priority="70"><arg num="1"/> == <arg num="2"/></apply>
+ <impl position="freestanding">operator == (<arg-list/>)</impl>
+ </op>
+
+ <op name="not-equal-to">
+ <apply priority="70"><arg num="1"/> != <arg num="2"/></apply>
+ <impl position="freestanding">operator != (<arg-list/>)</impl>
+ </op>
+
+ <op name="bitwise-and">
+ <apply priority="65" assoc="1"><arg num="1"/> &amp; <arg num="2"/></apply>
+ <impl position="freestanding">operator &amp; (<arg-list/>)</impl>
+ </op>
+
+ <op name="bitwise-or">
+ <apply priority="60" assoc="1"><arg num="1"/> | <arg num="2"/></apply>
+ <impl position="freestanding">operator | (<arg-list/>)</impl>
+ </op>
+
+ <op name="bitwise-xor">
+ <apply priority="55" assoc="1"><arg num="1"/> ^ <arg num="2"/></apply>
+ <impl position="freestanding">operator ^ (<arg-list/>)</impl>
+ </op>
+
+ <op name="logical-and">
+ <apply priority="50" assoc="1"><arg num="1"/> &amp;&amp; <arg num="2"/></apply>
+ <impl position="freestanding">operator &amp;&amp; (<arg-list/>)</impl>
+ </op>
+
+ <op name="logical-or">
+ <apply priority="45" assoc="1"><arg num="1"/> || <arg num="2"/></apply>
+ <impl position="freestanding">operator || (<arg-list/>)</impl>
+ </op>
+
+ <op name="conditional">
+ <apply priority="40" assoc="3"><arg num="1"/> ? <arg num="2"/> : <arg num="3"/></apply>
+ <impl>Error</impl>
+ </op>
+
+ <op name="assign">
+ <apply priority="35" assoc="2"><arg num="1"/> = <arg num="2"/></apply>
+ <impl position="method">operator = (<arg-list/>)</impl>
+ </op>
+
+ <op name="add-assign">
+ <apply priority="35" assoc="2"><arg num="1"/> += <arg num="2"/></apply>
+ <impl position="method">operator += (<arg-list/>)</impl>
+ </op>
+
+ <op name="subtract-assign">
+ <apply priority="35" assoc="2"><arg num="1"/> -= <arg num="2"/></apply>
+ <impl position="method">operator -= (<arg-list/>)</impl>
+ </op>
+
+ <op name="multiply-assign">
+ <apply priority="35" assoc="2"><arg num="1"/> *= <arg num="2"/></apply>
+ <impl position="method">operator *= (<arg-list/>)</impl>
+ </op>
+
+ <op name="divide-assign">
+ <apply priority="35" assoc="2"><arg num="1"/> /= <arg num="2"/></apply>
+ <impl position="method">operator /= (<arg-list/>)</impl>
+ </op>
+
+ <op name="modulus-assign">
+ <apply priority="35" assoc="2"><arg num="1"/> %= <arg num="2"/></apply>
+ <impl position="method">operator %= (<arg-list/>)</impl>
+ </op>
+
+ <op name="shift-left-assign">
+ <apply priority="35" assoc="2"><arg num="1"/> &lt;&lt;= <arg num="2"/></apply>
+ <impl position="method">operator &lt;&lt;= (<arg-list/>)</impl>
+ </op>
+
+ <op name="shift-right-assign">
+ <apply priority="35" assoc="2"><arg num="1"/> &gt;&gt;= <arg num="2"/></apply>
+ <impl position="method">operator &gt;&gt;= (<arg-list/>)</impl>
+ </op>
+
+ <op name="bitwise-and-assign">
+ <apply priority="35" assoc="2"><arg num="1"/> &amp;= <arg num="2"/></apply>
+ <impl position="method">operator &amp;= (<arg-list/>)</impl>
+ </op>
+
+ <op name="bitwise-or-assign">
+ <apply priority="35" assoc="2"><arg num="1"/> |= <arg num="2"/></apply>
+ <impl position="method">operator |= (<arg-list/>)</impl>
+ </op>
+
+ <op name="bitwise-xor-assign">
+ <apply priority="35" assoc="2"><arg num="1"/> ^= <arg num="2"/></apply>
+ <impl position="method">operator ^= (<arg-list/>)</impl>
+ </op>
+
+ <op name="comma">
+ <apply priority="20"><arg num="1"/>, <arg num="2"/></apply>
+ <impl position="freestanding">operator , (<arg-list/>)</impl>
+ </op>
+
+ <op name="function-pointer">
+ <apply><arg num="1"/> (*)(<arg-list start="2" priority="30"/>)</apply>
+ <impl>Error</impl>
+ </op>
+
+ <op name="functorize-operator">
+ <!-- Note: non-testable constraint -->
+ <apply>functorization of operator <name/> on arguments {<arg-list start="1"/>}</apply>
+ <impl>Error</impl>
+ </op>
+
+ <op name="functorize-function">
+ <!-- Note: non-testable constraint -->
+ <apply>functorization of function <name/> on arguments {<arg-list start="1"/>}</apply>
+ <impl>Error</impl>
+ </op>
+
+</operator-list>
diff --git a/src/boost/tools/boostbook/xsl/caramel/unparser.xsl b/src/boost/tools/boostbook/xsl/caramel/unparser.xsl
new file mode 100644
index 000000000..63db55fff
--- /dev/null
+++ b/src/boost/tools/boostbook/xsl/caramel/unparser.xsl
@@ -0,0 +1,497 @@
+<?xml version="1.0" ?>
+
+<!--
+Copyright (c) 2002-2003 The Trustees of Indiana University.
+ All rights reserved.
+Copyright (c) 2000-2001 University of Notre Dame. All rights reserved.
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt) -->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:template name="unparse-cpp">
+ <xsl:param name="typeref"/>
+ <xsl:param name="definition_list"/>
+ <xsl:param name="priority">0</xsl:param>
+ <xsl:param name="ignore-cv" select="false()"/>
+ <xsl:param name="ignore-references" select="false()"/>
+ <xsl:param name="notations"/>
+ <xsl:param name="ignore-notation" select="false()"/>
+ <xsl:param name="print-updated-notation" select="false()"/>
+ <xsl:param name="use-typename" select="false()"/>
+ <xsl:param name="const-if-not-mutable-value" select="'const-if-not-mutable'"/>
+
+ <xsl:variable name="notation_check">
+ <xsl:if test="not($ignore-notation)"> <!-- Prevent infinite recursion -->
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="$typeref"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="priority">0</xsl:with-param>
+ <xsl:with-param name="ignore-cv" select="true()"/>
+ <xsl:with-param name="ignore-references" select="true()"/>
+ <xsl:with-param name="notations" select="$notations"/>
+ <xsl:with-param name="ignore-notation" select="true()"/>
+ <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+
+ <!--
+ <xsl:message>Notation check: <xsl:value-of select="$notation_check"/>
+ Notations: <xsl:value-of select="$notations"/>
+ </xsl:message> -->
+
+ <xsl:variable name="this_op_priority" select="document('cpp-operators.xml')/operator-list/op[@name=name($typeref)]/apply/@priority"/>
+
+ <xsl:variable name="result">
+
+ <xsl:variable name="subcall_priority">
+ <xsl:choose>
+ <xsl:when test="true() or ($this_op_priority &gt; $priority)">
+ <xsl:value-of select="$this_op_priority"/>
+ </xsl:when>
+ <!-- <xsl:otherwise>0</xsl:otherwise> -->
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:if test="$this_op_priority &lt;= $priority">(</xsl:if>
+
+ <xsl:choose>
+
+ <xsl:when test="name($typeref)='sample-value'"
+ >boost::sample_value &lt; <xsl:call-template name="unparse-cpp"><xsl:with-param name="typeref" select="$typeref/*[1]"/><xsl:with-param name="definition_list" select="$definition_list"/><xsl:with-param name="ignore-cv" select="$ignore-cv"/><xsl:with-param name="notations" select="$notations"/><xsl:with-param name="ignore-references" select="$ignore-references"/><xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/></xsl:call-template> &gt;()</xsl:when>
+
+ <xsl:when test="name($typeref)='reference-to'"
+ ><xsl:call-template name="unparse-cpp"><xsl:with-param name="typeref" select="$typeref/*[1]"/><xsl:with-param name="definition_list" select="$definition_list"/><xsl:with-param name="priority" select="$subcall_priority"/><xsl:with-param name="ignore-cv" select="$ignore-cv"/><xsl:with-param name="notations" select="$notations"/><xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/></xsl:call-template><xsl:if test="not($ignore-references)"> &amp;</xsl:if></xsl:when>
+
+ <xsl:when test="name($typeref)='pointer-to'"
+ ><xsl:call-template name="unparse-cpp"><xsl:with-param name="typeref" select="$typeref/*[1]"/><xsl:with-param name="definition_list" select="$definition_list"/><xsl:with-param name="priority" select="$subcall_priority"/><xsl:with-param name="ignore-cv" select="$ignore-cv"/><xsl:with-param name="notations" select="$notations"/></xsl:call-template> *</xsl:when>
+
+ <xsl:when test="name($typeref)='const'"
+ ><xsl:if test="not($ignore-cv)">const </xsl:if><xsl:call-template name="unparse-cpp"><xsl:with-param name="typeref" select="$typeref/*[1]"/><xsl:with-param name="definition_list" select="$definition_list"/><xsl:with-param name="priority" select="$subcall_priority"/><xsl:with-param name="ignore-cv" select="$ignore-cv"/><xsl:with-param name="notations" select="$notations"/><xsl:with-param name="ignore-references" select="$ignore-references"/><xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/></xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="name($typeref)='const-if-not-mutable'"
+ ><xsl:if test="not($ignore-cv)"><xsl:value-of select="$const-if-not-mutable-value"/><xsl:if test="$const-if-not-mutable-value"><xsl:text> </xsl:text></xsl:if></xsl:if><xsl:call-template name="unparse-cpp"><xsl:with-param name="typeref" select="$typeref/*[1]"/><xsl:with-param name="definition_list" select="$definition_list"/><xsl:with-param name="priority" select="$subcall_priority"/><xsl:with-param name="ignore-cv" select="$ignore-cv"/><xsl:with-param name="notations" select="$notations"/><xsl:with-param name="ignore-references" select="$ignore-references"/><xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/></xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="name($typeref)='volatile'"
+ ><xsl:if test="not($ignore-cv)">volatile </xsl:if><xsl:call-template name="unparse-cpp"><xsl:with-param name="typeref" select="$typeref/*[1]"/><xsl:with-param name="definition_list" select="$definition_list"/><xsl:with-param name="priority" select="$subcall_priority"/><xsl:with-param name="ignore-cv" select="$ignore-cv"/><xsl:with-param name="notations" select="$notations"/><xsl:with-param name="ignore-references" select="$ignore-references"/><xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/></xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="name($typeref)='apply-template'">
+ <xsl:value-of select="$typeref/@name"/>&lt;<xsl:for-each select="$typeref/*">
+ <xsl:if test="position()!=1">, </xsl:if><xsl:comment/>
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="."/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="ignore-cv" select="$ignore-cv"/>
+ <xsl:with-param name="notations" select="$notations"/>
+ <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/>
+ </xsl:call-template></xsl:for-each
+ ><xsl:comment/>&gt;</xsl:when>
+
+ <xsl:when test="name($typeref)='get-member-type'">
+ <xsl:call-template name="unparse-cpp"><xsl:with-param name="typeref" select="$typeref/*[1]"/><xsl:with-param name="definition_list" select="$definition_list"/><xsl:with-param name="ignore-cv" select="$ignore-cv"/><xsl:with-param name="notations" select="$notations"/><xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/></xsl:call-template>::<xsl:value-of select="$typeref/@name"/>
+ </xsl:when>
+
+ <xsl:when test="name($typeref)='type'">
+ <xsl:variable name="typeref_value" select="normalize-space(substring-before(substring-after($definition_list,concat('@(@',$typeref/@name,'=')),'@)@'))"/>
+ <xsl:choose>
+ <xsl:when test="$typeref_value=''">
+ <xsl:value-of select="$typeref/@name"/><xsl:comment/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$typeref_value"/><xsl:comment/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:when test="name($typeref)='documentation'"/>
+
+ <xsl:when test="document('cpp-operators.xml')/operator-list/op[@name=name($typeref)]">
+ <xsl:variable name="op_file" select="document('cpp-operators.xml')/operator-list"/>
+ <xsl:variable name="op_info" select="$op_file/op[@name=name($typeref)]/apply/."/>
+
+ <xsl:call-template name="unparse-operator-definition">
+ <xsl:with-param name="typeref" select="$typeref"/>
+ <xsl:with-param name="operator_nodeset" select="$op_info/child::node()"/>
+ <xsl:with-param name="my_priority" select="$subcall_priority"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="notations" select="$notations"/>
+ <xsl:with-param name="ignore-cv" select="$ignore-cv"/>
+ <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/>
+ <xsl:with-param name="print-updated-notation" select="$print-updated-notation"/>
+ </xsl:call-template>
+
+ </xsl:when>
+
+ <xsl:otherwise>
+ (Unrecognized tag <xsl:value-of select="name($typeref)"/>)
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <!-- Close parenthesis code moved below -->
+
+ </xsl:variable>
+
+ <!-- <xsl:message>ignore-notation = <xsl:value-of select="$ignore-notation"/></xsl:message> -->
+ <!-- <xsl:message>notation_check = <xsl:value-of select="$notation_check"/></xsl:message> -->
+ <!-- <xsl:message>notations = <xsl:value-of select="$notations"/></xsl:message> -->
+ <!-- <xsl:message>result = <xsl:value-of select="$result"/></xsl:message> -->
+
+ <xsl:variable name="used_notation" select="boolean($notation_check) and boolean(substring-before(substring-after($notations, concat('@@(@@', $notation_check, '@@=@@')),'@@)@@'))"/>
+
+ <xsl:variable name="notations2">
+ <!-- Possibly replace from result of unparse-operator-definition -->
+ <xsl:choose>
+ <xsl:when test="contains($result, ' *@@@* ')">
+ <xsl:value-of select="substring-after($result, ' *@@@* ')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$notations"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="result2">
+ <!-- Possibly replace from result of unparse-operator-definition -->
+ <xsl:choose>
+ <xsl:when test="contains($result, ' *@@@* ')">
+ <xsl:value-of select="substring-before($result, ' *@@@* ')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$result"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <!-- Close parenthesis code -->
+ <xsl:if test="$this_op_priority &lt;= $priority">)</xsl:if>
+ </xsl:variable>
+
+ <xsl:variable name="notation_varlist">
+ <xsl:choose>
+ <xsl:when test="$used_notation">
+ <xsl:value-of select="substring-before(substring-after($notations2, concat('@@(@@', $notation_check, '@@=@@')), '@@)@@')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$result2"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="new_varlist" select="substring-after(normalize-space($notation_varlist), ' ')"/>
+
+ <xsl:variable name="notation_var">
+ <xsl:choose>
+ <xsl:when test="not($used_notation)">
+ <xsl:value-of select="$result2"/>
+ </xsl:when>
+ <xsl:when test="$new_varlist=''">
+ <xsl:value-of select="$notation_varlist"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="substring-before(normalize-space($notation_varlist), ' ')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- Generate new notation list -->
+ <xsl:variable name="new_notations">
+ <xsl:choose>
+ <xsl:when test="$used_notation">
+ <xsl:value-of select="normalize-space(concat('@@(@@', $notation_check, '@@=@@', $new_varlist, '@@)@@', $notations2))"/>
+ <!-- Duplicate entries always use first occurrance, so I can optimize this -->
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="$notations2"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- <xsl:message>final_result = <xsl:value-of select="normalize-space($final_result)"/></xsl:message> -->
+
+ <xsl:call-template name="add-typename"><xsl:with-param name="really-do-it" select="$use-typename"/><xsl:with-param name="type"><xsl:value-of select="normalize-space($notation_var)"/></xsl:with-param></xsl:call-template><xsl:if test="$print-updated-notation"> *@@@* <xsl:value-of select="$new_notations"/></xsl:if>
+
+ </xsl:template>
+
+ <xsl:template name="unparse-operator-definition">
+ <xsl:param name="typeref"/>
+ <xsl:param name="operator_nodeset"/>
+ <xsl:param name="current_start">1</xsl:param>
+ <xsl:param name="my_priority"/>
+ <xsl:param name="definition_list"/>
+ <xsl:param name="notations"/>
+ <xsl:param name="ignore-cv"/>
+ <xsl:param name="self"/>
+ <xsl:param name="use-code-block" select="false()"/>
+ <xsl:param name="print-updated-notation" select="false()"/>
+ <xsl:param name="const-if-not-mutable-value"/>
+
+ <xsl:variable name="op_current" select="$operator_nodeset[position()=1]"/>
+ <xsl:variable name="op_rest" select="$operator_nodeset[position()!=1]"/>
+
+ <xsl:choose>
+
+ <xsl:when test="count($operator_nodeset)=0">
+ <xsl:if test="$print-updated-notation"> *@@@* <xsl:value-of select="$notations"/></xsl:if>
+ </xsl:when>
+
+ <xsl:when test="$op_current != $op_current/../*"> <!-- If I am not an element -->
+ <xsl:value-of select="$op_current"/>
+ <xsl:call-template name="unparse-operator-definition">
+ <xsl:with-param name="typeref" select="$typeref"/>
+ <xsl:with-param name="operator_nodeset" select="$op_rest"/>
+ <xsl:with-param name="my_priority" select="$my_priority"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="notations" select="$notations"/>
+ <xsl:with-param name="self" select="$self"/>
+ <xsl:with-param name="use-code-block" select="$use-code-block"/>
+ <xsl:with-param name="print-updated-notation" select="$print-updated-notation"/>
+ <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="name($op_current)='name'">
+ <xsl:value-of select="$typeref/@name"/>
+ <xsl:call-template name="unparse-operator-definition">
+ <xsl:with-param name="typeref" select="$typeref"/>
+ <xsl:with-param name="operator_nodeset" select="$op_rest"/>
+ <xsl:with-param name="my_priority" select="$my_priority"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="notations" select="$notations"/>
+ <xsl:with-param name="ignore-cv" select="$ignore-cv"/>
+ <xsl:with-param name="self" select="$self"/>
+ <xsl:with-param name="use-code-block" select="$use-code-block"/>
+ <xsl:with-param name="print-updated-notation" select="$print-updated-notation"/>
+ <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="name($op_current)='self'">
+ <xsl:call-template name="concept.link">
+ <xsl:with-param name="name" select="string($self)"/>
+ </xsl:call-template>
+ <xsl:call-template name="unparse-operator-definition">
+ <xsl:with-param name="typeref" select="$typeref"/>
+ <xsl:with-param name="operator_nodeset" select="$op_rest"/>
+ <xsl:with-param name="my_priority" select="$my_priority"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="notations" select="$notations"/>
+ <xsl:with-param name="ignore-cv" select="$ignore-cv"/>
+ <xsl:with-param name="self" select="$self"/>
+ <xsl:with-param name="use-code-block" select="$use-code-block"/>
+ <xsl:with-param name="print-updated-notation" select="$print-updated-notation"/>
+ <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="name($op_current)='arg'">
+ <xsl:variable name="num" select="$op_current/@num"/>
+ <xsl:variable name="assoc" select="$op_current/../@assoc"/>
+ <xsl:variable name="my_priority_before" select="$my_priority"/>
+ <xsl:variable name="my_priority">
+ <xsl:choose>
+ <xsl:when test="count($op_current/@priority)">
+ <xsl:value-of select="$op_current/@priority"/>
+ </xsl:when>
+ <xsl:when test="$assoc and ($num = $assoc)">
+ <xsl:value-of select="$my_priority_before - 1"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$my_priority"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="typeref-result">
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="$typeref/*[position()=$num]"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="priority" select="$my_priority"/>
+ <xsl:with-param name="ignore-cv" select="$ignore-cv"/>
+ <xsl:with-param name="notations" select="$notations"/>
+ <xsl:with-param name="print-updated-notation" select="true()"/>
+ <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="typeref-print" select="normalize-space(substring-before($typeref-result, ' *@@@* '))"/>
+ <xsl:variable name="new_notations" select="normalize-space(substring-after($typeref-result, ' *@@@* '))"/>
+
+ <xsl:choose>
+ <xsl:when test="$use-code-block">
+ <type><xsl:value-of select="$typeref-print"/></type>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$typeref-print"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:call-template name="unparse-operator-definition">
+ <xsl:with-param name="typeref" select="$typeref"/>
+ <xsl:with-param name="operator_nodeset" select="$op_rest"/>
+ <xsl:with-param name="my_priority" select="$my_priority_before"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="notations" select="$new_notations"/>
+ <xsl:with-param name="ignore-cv" select="$ignore-cv"/>
+ <xsl:with-param name="self" select="$self"/>
+ <xsl:with-param name="use-code-block" select="$use-code-block"/>
+ <xsl:with-param name="print-updated-notation" select="$print-updated-notation"/>
+ <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="name($op_current)='arg-list'">
+ <xsl:variable name="start" select="$op_current/@start"/>
+ <xsl:variable name="typeref-result">
+ <xsl:choose>
+ <xsl:when test="$current_start &gt;= $start">
+ <xsl:call-template name="unparse-cpp">
+ <xsl:with-param name="typeref" select="$typeref/*[$current_start]"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="priority" select="$my_priority"/>
+ <xsl:with-param name="ignore-cv" select="$ignore-cv"/>
+ <xsl:with-param name="notations" select="$notations"/>
+ <xsl:with-param name="print-updated-notation" select="true()"/>
+ <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:otherwise>
+ *@@@* <xsl:value-of select="$notations"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="typeref-print" select="normalize-space(substring-before($typeref-result, ' *@@@* '))"/>
+ <xsl:variable name="new_notations" select="normalize-space(substring-after($typeref-result, ' *@@@* '))"/>
+
+ <xsl:choose>
+ <xsl:when test="$use-code-block">
+ <type><xsl:value-of select="$typeref-print"/></type>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$typeref-print"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:if test="$current_start &gt;= $start">
+ <xsl:if test="$current_start!=count($typeref/*)">, </xsl:if>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="$current_start != count($typeref/*)">
+ <xsl:call-template name="unparse-operator-definition">
+ <xsl:with-param name="typeref" select="$typeref"/>
+ <xsl:with-param name="operator_nodeset" select="$operator_nodeset"/>
+ <xsl:with-param name="current_start" select="$current_start + 1"/>
+ <xsl:with-param name="my_priority" select="$my_priority"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="notations" select="$new_notations"/>
+ <xsl:with-param name="ignore-cv" select="$ignore-cv"/>
+ <xsl:with-param name="self" select="$self"/>
+ <xsl:with-param name="use-code-block" select="$use-code-block"/>
+ <xsl:with-param name="print-updated-notation" select="$print-updated-notation"/>
+ <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="unparse-operator-definition">
+ <xsl:with-param name="typeref" select="$typeref"/>
+ <xsl:with-param name="operator_nodeset" select="$op_rest"/>
+ <xsl:with-param name="my_priority" select="$my_priority"/>
+ <xsl:with-param name="definition_list" select="$definition_list"/>
+ <xsl:with-param name="notations" select="$new_notations"/>
+ <xsl:with-param name="ignore-cv" select="$ignore-cv"/>
+ <xsl:with-param name="self" select="$self"/>
+ <xsl:with-param name="use-code-block" select="$use-code-block"/>
+ <xsl:with-param name="const-if-not-mutable-value" select="$const-if-not-mutable-value"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:otherwise>Invalid tag in operator definition: <xsl:value-of select="name($op_current)"/></xsl:otherwise>
+
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="add-typename">
+ <!-- Adds typename to the front of a string if it is necessary. -->
+ <xsl:param name="type"/> <!-- string to prepend to -->
+ <xsl:param name="params" select="/concept/param | /concept/define-type | /concept/associated-type"/>
+ <!-- nodeset of param tags for concept -->
+ <!-- associated types are assumed to be dependent -->
+ <xsl:param name="really-do-it"/> <!-- really change anything? -->
+
+ <xsl:variable name="type-after-last-scope">
+ <xsl:call-template name="substring-before-last">
+ <xsl:with-param name="string" select="$type"/>
+ <xsl:with-param name="to-find" select="'::'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="tokenized-type-after-last-scope">
+ <xsl:call-template name="rough-tokenize">
+ <xsl:with-param name="string" select="$type-after-last-scope"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$really-do-it and boolean($params[contains($tokenized-type-after-last-scope, concat(' ', @name, ' '))])">
+ <!-- If the tokenized string contains any of the param names in a
+ token by itself, return true. Return false otherwise -->
+ <xsl:comment/>typename <xsl:value-of select="$type"/><xsl:comment/>
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="$type"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="substring-before-last">
+ <xsl:param name="string"/>
+ <xsl:param name="to-find"/>
+ <xsl:param name="string-processed-so-far"/> <!-- internal -->
+ <!-- Find the substring of $string before the last occurrance of
+ $to-find, returning '' if it was not found. -->
+
+ <xsl:choose>
+ <xsl:when test="contains($string, $to-find)">
+ <xsl:call-template name="substring-before-last">
+ <xsl:with-param name="string" select="substring-after($string, $to-find)"/>
+ <xsl:with-param name="to-find" select="$to-find"/>
+ <xsl:with-param name="string-processed-so-far" select="concat($string-processed-so-far, substring-before($string, $to-find), $to-find)"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:value-of select="substring($string-processed-so-far, 1, string-length($string-processed-so-far)-(string-length($to-find)))"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="substring-after-last">
+ <xsl:param name="string"/>
+ <xsl:param name="to-find"/>
+ <!-- Find the substring of $string after the last occurrance of
+ $to-find, returning the original string if it was not found. -->
+
+ <xsl:choose>
+ <xsl:when test="contains($string, $to-find)">
+ <xsl:call-template name="substring-after-last">
+ <xsl:with-param name="string" select="substring-after($string, $to-find)"/>
+ <xsl:with-param name="to-find" select="$to-find"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:value-of select="$string"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="rough-tokenize">
+ <xsl:param name="string"/>
+ <!-- Do a rough tokenization of the string. Right now, just translate
+ all non-token-chars to spaces, normalize-space the result, and prepend
+ and append spaces. -->
+
+ <xsl:value-of select="concat(' ', normalize-space(translate($string, '&lt;&gt;,./?;:[]{}-=\\_+|!@#$%^&amp;*()', ' ')), ' ')"/>
+ </xsl:template>
+</xsl:stylesheet>