]> granicus.if.org Git - docbook-dsssl/commitdiff
Initial checkin
authorNorman Walsh <ndw@nwalsh.com>
Fri, 28 Sep 2001 20:20:01 +0000 (20:20 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Fri, 28 Sep 2001 20:20:01 +0000 (20:20 +0000)
litprog/.cvsignore [new file with mode: 0644]
litprog/Makefile [new file with mode: 0644]
litprog/README [new file with mode: 0644]
litprog/VERSION [new file with mode: 0644]
litprog/bootstrap-tangle.xsl [new file with mode: 0644]
litprog/litprog.dtd [new file with mode: 0644]
litprog/litprog.xweb [new file with mode: 0644]
litprog/tangle.xweb [new file with mode: 0644]
litprog/weave.xweb [new file with mode: 0644]

diff --git a/litprog/.cvsignore b/litprog/.cvsignore
new file mode 100644 (file)
index 0000000..20344c9
--- /dev/null
@@ -0,0 +1,10 @@
+litprog.xml
+litprog.xsl
+litprog.html
+weave.xml
+weave.xsl
+weave.html
+tangle.xml
+tangle.xsl
+tangle.html
+
diff --git a/litprog/Makefile b/litprog/Makefile
new file mode 100644 (file)
index 0000000..47143d2
--- /dev/null
@@ -0,0 +1,36 @@
+include ../cvstools/Makefile.incl
+
+all: tangle.html weave.html litprog.html
+
+tangle.html: tangle.xml litprog.xsl
+       $(XSLT) $< litprog.xsl $@
+
+tangle.xml: tangle.xweb weave.xsl
+       $(XSLT) $< weave.xsl $@
+
+# Can this rule be improved? Ideally bootstrap-tangle should only be
+# required if tangle.xsl doesn't exist. If it exists but is out-of-date
+# it can rebuild itself.
+tangle.xsl: tangle.xweb bootstrap-tangle.xsl
+       $(XSLT) $< bootstrap-tangle.xsl .temp.xsl
+       $(XSLT) $< .temp.xsl tangle.xsl
+       rm -f .temp.xsl
+
+weave.html: weave.xml litprog.xsl
+       $(XSLT)  $< litprog.xsl $@
+
+weave.xml: weave.xweb weave.xsl
+       $(XSLT)  $< weave.xsl $@
+       xjparse $@
+
+weave.xsl: weave.xweb tangle.xsl
+       $(XSLT)  $< tangle.xsl $@
+
+litprog.html: litprog.xml litprog.xsl
+       $(XSLT) $< litprog.xsl $@
+
+litprog.xml: litprog.xweb weave.xsl
+       $(XSLT) $< weave.xsl $@
+
+litprog.xsl: litprog.xweb tangle.xsl
+       $(XSLT) $< tangle.xsl $@
diff --git a/litprog/README b/litprog/README
new file mode 100644 (file)
index 0000000..9ec4527
--- /dev/null
@@ -0,0 +1,4 @@
+This is an experimental litprog system that norm is working on.
+It's not ready for prime time. It's not ready to be packaged up.
+It may not even be ready for external review.
+Avert your eyes! :-)
diff --git a/litprog/VERSION b/litprog/VERSION
new file mode 100644 (file)
index 0000000..58e35e3
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version='1.0'>
+<xsl:param name="VERSION">0.00+</xsl:param>
+</xsl:stylesheet>
+
diff --git a/litprog/bootstrap-tangle.xsl b/litprog/bootstrap-tangle.xsl
new file mode 100644 (file)
index 0000000..9820a53
--- /dev/null
@@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+<!DOCTYPE xsl:stylesheet [
+<!ENTITY nl "<xsl:text>&#xA;</xsl:text>">
+]>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:src="http://nwalsh.com/xmlns/litprog/fragment"
+                version="1.0">
+
+<xsl:preserve-space elements="*"/>
+
+<xsl:output method="xml"/>
+
+<xsl:template match="/">
+  <xsl:apply-templates select="//src:topfragment"/>
+</xsl:template>
+
+<xsl:template match="text()"/>
+
+<xsl:template match="*">
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="src:topfragment">
+  <xsl:apply-templates mode="copy"/>
+</xsl:template>
+
+<xsl:template match="src:fragment">
+  <xsl:apply-templates mode="copy"/>
+</xsl:template>
+
+<xsl:template match="*" mode="copy">
+  <!--
+  <xsl:message><xsl:value-of select="name(.)"/></xsl:message>
+  -->
+  <xsl:element name="{name(.)}">
+    <xsl:for-each select="namespace::*">
+      <!--
+      <xsl:message><xsl:value-of select="."/></xsl:message>
+      -->
+      <xsl:copy/>
+    </xsl:for-each>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="copy"/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="src:passthrough" mode="copy">
+  <xsl:value-of disable-output-escaping="yes" select="."/>
+</xsl:template>
+
+<xsl:template match="src:fragref" mode="copy">
+  <xsl:choose>
+    <xsl:when test="@disable-output-escaping='yes'">
+      <xsl:element name="{name(.)}">
+        <xsl:for-each select="namespace::*">
+          <xsl:copy/>
+        </xsl:for-each>
+        <xsl:for-each select="@*">
+          <xsl:if test="not(name(.) = 'disable-output-escaping')">
+            <xsl:copy/>
+          </xsl:if>
+        </xsl:for-each>
+        <xsl:apply-templates mode="copy"/>
+      </xsl:element>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:variable name="linkend" select="@linkend"/>
+      <xsl:variable name="fragment" select="//src:fragment[@id=$linkend]"/>
+      <xsl:apply-templates select="$fragment"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="src:comment" mode="copy">
+  <xsl:comment>
+    <xsl:value-of select="."/>
+  </xsl:comment>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/litprog/litprog.dtd b/litprog/litprog.dtd
new file mode 100644 (file)
index 0000000..a928b36
--- /dev/null
@@ -0,0 +1,32 @@
+<!ENTITY % docbook
+  PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+         "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
+
+<!ENTITY % local.link.char.class "|src:fragref">
+<!ENTITY % local.linespecific.class "|src:fragment">
+
+<!ENTITY % local.article.attrib "
+       xmlns:src       CDATA   #IMPLIED
+       xmlns:xsl       CDATA   #IMPLIED
+">
+
+
+%docbook;
+
+<!ELEMENT src:fragment (%para.char.mix; | co | lineannotation)*>
+<!ATTLIST src:fragment
+               %width.attrib;
+               %linespecific.attrib;
+               %common.attrib;
+               %role.attrib;
+>
+
+<!ELEMENT src:fragref (%para.char.mix;)*>
+<!ATTLIST src:fragref
+               disable-output-escaping (yes|no)        "no"
+               endterm         IDREF           #IMPLIED
+               %linkendreq.attrib;
+               type            CDATA           #IMPLIED
+               %common.attrib;
+               %role.attrib;
+>
diff --git a/litprog/litprog.xweb b/litprog/litprog.xweb
new file mode 100644 (file)
index 0000000..2493ef8
--- /dev/null
@@ -0,0 +1,157 @@
+<article xmlns:src="http://nwalsh.com/xmlns/litprog/fragment"
+         xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<title>Litprog.xsl</title>
+
+<src:topfragment id="top" default-exclude-result-prefixes="xsl">
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:src="http://nwalsh.com/xmlns/litprog/fragment"
+                xmlns:verb="com.nwalsh.saxon.Verbatim"
+                exclude-result-prefixes="verb src"
+                version="1.0">
+  <src:fragref linkend="rest"/>
+</xsl:stylesheet>
+</src:topfragment>
+
+<section><title>The Rest</title>
+
+<src:fragment id="rest">
+<xsl:import href="../xsl/html/docbook.xsl"/>
+
+<xsl:param name="local.l10n.xml" select="document('')"/>
+
+<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
+  <l:l10n language="en">
+   <l:context name="title">
+      <l:template name="fragment" text="%t"/>
+    </l:context>
+  </l:l10n>
+</l:i18n>
+
+<xsl:param name="section.autolabel" select="1"/>
+<xsl:param name="linenumbering.everyNth" select="'3'"/>
+<xsl:param name="linenumbering.separator" select="'|'"/>
+
+<xsl:output method="html"/>
+
+<xsl:template match="src:fragment">
+  <xsl:param name="suppress-numbers" select="'0'"/>
+  <xsl:param name="linenumbering" select="'numbered'"/>
+  <xsl:variable name="section" select="ancestor::section[1]"/>
+
+  <a name="{@id}"/>
+  <table border="1" width="100%">
+    <tr>
+      <td>
+        <p>
+          <b>
+            <xsl:text>&#xA7;</xsl:text>
+            <xsl:apply-templates select="$section" mode="label.markup"/>
+            <xsl:number from="section"/>
+          </b>
+        </p>
+      </td>
+    </tr>
+    <tr>
+      <td>
+        <xsl:choose>
+          <xsl:when test="$suppress-numbers = '0'
+                          and $linenumbering = 'numbered'
+                          and $use.extensions != '0'
+                          and $linenumbering.extension != '0'">
+            <xsl:variable name="rtf">
+              <xsl:apply-templates/>
+            </xsl:variable>
+            <pre class="{name(.)}">
+              <xsl:copy-of select="verb:numberLines($rtf)"/>
+            </pre>
+          </xsl:when>
+          <xsl:otherwise>
+            <pre class="{name(.)}">
+              <xsl:apply-templates/>
+            </pre>
+          </xsl:otherwise>
+        </xsl:choose>
+      </td>
+    </tr>
+  </table>
+</xsl:template>
+
+<xsl:template match="src:fragref">
+  <xsl:variable name="targets" select="id(@linkend)"/>
+  <xsl:variable name="target" select="$targets[1]"/>
+  <xsl:variable name="refelem" select="local-name($target)"/>
+
+  <xsl:call-template name="check.id.unique">
+    <xsl:with-param name="linkend" select="@linkend"/>
+  </xsl:call-template>
+
+  <i><xsl:apply-templates/></i>
+  <xsl:text> (</xsl:text>
+
+  <xsl:choose>
+    <xsl:when test="$refelem=''">
+      <xsl:message>
+       <xsl:text>XRef to nonexistent id: </xsl:text>
+       <xsl:value-of select="@linkend"/>
+      </xsl:message>
+      <xsl:text>???</xsl:text>
+    </xsl:when>
+
+    <xsl:when test="$target/@xreflabel">
+      <a>
+        <xsl:attribute name="href">
+          <xsl:call-template name="href.target">
+            <xsl:with-param name="object" select="$target"/>
+          </xsl:call-template>
+        </xsl:attribute>
+        <xsl:call-template name="xref.xreflabel">
+          <xsl:with-param name="target" select="$target"/>
+        </xsl:call-template>
+      </a>
+    </xsl:when>
+
+    <xsl:otherwise>
+      <a>
+        <xsl:attribute name="href">
+          <xsl:call-template name="href.target">
+            <xsl:with-param name="object" select="$target"/>
+          </xsl:call-template>
+        </xsl:attribute>
+
+        <xsl:apply-templates select="id(@linkend)" mode="xref-to-section"/>
+      </a>
+    </xsl:otherwise>
+  </xsl:choose>
+  <xsl:text>)</xsl:text>
+</xsl:template>
+
+<xsl:template match="src:fragment" mode="xref-to">
+  <xsl:variable name="section" select="ancestor::section[1]"/>
+
+  <i>
+    <xsl:text>&#xA7;</xsl:text>
+    <xsl:apply-templates select="$section" mode="label.markup"/>
+    <xsl:number from="section"/>
+    <xsl:text>. </xsl:text>
+    <xsl:apply-templates select="$section" mode="title.markup"/>
+  </i>
+</xsl:template>
+
+<xsl:template match="src:fragment" mode="xref-to-section">
+  <xsl:variable name="section" select="ancestor::section[1]"/>
+
+  <i>
+    <xsl:text>&#xA7;</xsl:text>
+    <xsl:apply-templates select="$section" mode="label.markup"/>
+    <xsl:number from="section"/>
+  </i>
+</xsl:template>
+
+<xsl:template match="src:fragment" mode="title.markup">
+  <xsl:text>SRC:FRAGMENT TITLE</xsl:text>
+</xsl:template>
+
+</src:fragment>
+</section>
+
+</article>
diff --git a/litprog/tangle.xweb b/litprog/tangle.xweb
new file mode 100644 (file)
index 0000000..aa5b722
--- /dev/null
@@ -0,0 +1,120 @@
+<article xmlns:src="http://nwalsh.com/xmlns/litprog/fragment"
+         xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<title>Tangle.xsl</title>
+
+<src:topfragment id="top" default-exclude-result-prefixes="xsl">
+<src:passthrough>
+&lt;!DOCTYPE xsl:stylesheet [
+&lt;!ENTITY nl "&lt;xsl:text>&#xA;&lt;/xsl:text>">
+]>
+</src:passthrough>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:src="http://nwalsh.com/xmlns/litprog/fragment"
+                version="1.0">
+
+  <xsl:include href="VERSION"/>
+
+  <src:fragref linkend="space"/>
+  <src:fragref linkend="output"/>
+  <src:fragref linkend="root.template"/>
+  <src:fragref linkend="text"/>
+  <src:fragref linkend="default"/>
+  <src:fragref linkend="rest"/>
+</xsl:stylesheet>
+</src:topfragment>
+
+<section><title>Stuff</title>
+
+<src:fragment id="space">
+<xsl:preserve-space elements="*"/>
+</src:fragment>
+
+<src:fragment id="output">
+<xsl:output method="xml"/>
+</src:fragment>
+
+<src:fragment id="root.template">
+<xsl:template match="/">
+  <xsl:text>&#xA;</xsl:text>
+  <xsl:comment>
+    <xsl:text> This file was generated by tangle.xsl version </xsl:text>
+    <xsl:value-of select="$VERSION"/>
+    <xsl:text>. Do not edit! </xsl:text>
+  </xsl:comment>
+  <xsl:text>&#xA;</xsl:text>
+  <xsl:comment> See http://sourceforge.net/projects/docbook/ </xsl:comment>
+  <xsl:apply-templates select="//src:topfragment"/>
+</xsl:template>
+</src:fragment>
+
+<src:fragment id="text">
+<xsl:template match="text()"/>
+</src:fragment>
+
+<src:fragment id="default">
+<xsl:template match="*">
+  <xsl:apply-templates/>
+</xsl:template>
+</src:fragment>
+
+<src:fragment id="rest">
+<xsl:template match="src:topfragment">
+  <xsl:apply-templates mode="copy"/>
+</xsl:template>
+
+<xsl:template match="src:fragment">
+  <xsl:apply-templates mode="copy"/>
+</xsl:template>
+
+<xsl:template match="*" mode="copy">
+  <xsl:variable name="node" select="."/>
+  <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}">
+    <xsl:for-each select="namespace::*">
+      <xsl:if test="string(.) != namespace-uri($node)">
+        <xsl:copy/>
+      </xsl:if>
+    </xsl:for-each>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="copy"/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="src:passthrough" mode="copy">
+  <xsl:value-of disable-output-escaping="yes" select="."/>
+</xsl:template>
+
+<xsl:template match="src:fragref" mode="copy">
+  <xsl:variable name="node" select="."/>
+  <xsl:choose>
+    <xsl:when test="@disable-output-escaping='yes'">
+      <xsl:element name="{name(.)}" namespace="namespace-uri(.)">
+        <xsl:for-each select="namespace::*">
+          <xsl:if test="string(.) != namespace-uri($node)">
+            <xsl:copy/>
+          </xsl:if>
+        </xsl:for-each>
+        <xsl:for-each select="@*">
+          <xsl:if test="not(name(.) = 'disable-output-escaping')">
+            <xsl:copy/>
+          </xsl:if>
+        </xsl:for-each>
+        <xsl:apply-templates mode="copy"/>
+      </xsl:element>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:variable name="linkend" select="@linkend"/>
+      <xsl:variable name="fragment" select="//src:fragment[@id=$linkend]"/>
+      <xsl:apply-templates select="$fragment"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="src:comment" mode="copy">
+  <xsl:comment>
+    <xsl:value-of select="."/>
+  </xsl:comment>
+</xsl:template>
+</src:fragment>
+</section>
+</article>
+
diff --git a/litprog/weave.xweb b/litprog/weave.xweb
new file mode 100644 (file)
index 0000000..6c0ff2a
--- /dev/null
@@ -0,0 +1,418 @@
+<article xmlns:src="http://nwalsh.com/xmlns/litprog/fragment"
+         xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<title>Weave.xsl</title>
+
+<src:topfragment id="top" default-exclude-result-prefixes="xsl">
+<src:passthrough>
+&lt;!DOCTYPE xsl:stylesheet [
+&lt;!ENTITY nl "&lt;xsl:text>&#xA;&lt;/xsl:text>">
+]>
+</src:passthrough>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:src="http://nwalsh.com/xmlns/litprog/fragment"
+                exclude-result-prefixes="xsl src xml"
+                version="1.0">
+
+  <xsl:include href="VERSION"/>
+
+  <src:fragref linkend="space"/>
+  <src:fragref linkend="output"/>
+  <src:fragref linkend="param.ex.result.prefixes"/>
+  <src:fragref linkend="root.template"/>
+  <src:fragref linkend="default.template"/>
+  <src:fragref linkend="topfragment"/>
+  <src:fragref linkend="fragment"/>
+
+  <src:fragref linkend="rest"/>
+</xsl:stylesheet>
+</src:topfragment>
+
+<section><title>Whitespace Control</title>
+
+<src:fragment id="space">
+<xsl:preserve-space elements="*"/>
+</src:fragment>
+
+</section>
+<section><title>Output Method</title>
+
+<src:fragment id="output">
+<xsl:output method="xml"
+            doctype-public="-//DocBook Open Repository//DTD DocBook Literate Programming V0.0//EN"
+            doctype-system="litprog.dtd"/>
+</src:fragment>
+
+</section>
+<section><title>Default Exclude Result Prefixes</title>
+
+<src:fragment id="param.ex.result.prefixes">
+<xsl:param name="default-exclude-result-prefixes"
+           select="//src:topfragment/@default-exclude-result-prefixes"/>
+</src:fragment>
+
+</section>
+<section><title>Root Template</title>
+
+<src:fragment id="root.template">
+<xsl:template match="/">
+  <xsl:text>&#xA;</xsl:text>
+  <xsl:comment>
+    <xsl:text> This file was generated by weave.xsl version </xsl:text>
+    <xsl:value-of select="$VERSION"/>
+    <xsl:text>. Do not edit! </xsl:text>
+  </xsl:comment>
+  <xsl:text>&#xA;</xsl:text>
+  <xsl:comment> See http://sourceforge.net/projects/docbook/ </xsl:comment>
+  <xsl:apply-templates/>
+</xsl:template>
+</src:fragment>
+
+</section>
+<section><title>Default Template</title>
+
+<src:fragment id="default.template">
+<xsl:template match="*">
+  <xsl:variable name="node" select="."/>
+  <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}">
+    <xsl:for-each select="namespace::*">
+      <xsl:if test="string(.) != namespace-uri($node)">
+        <xsl:copy/>
+      </xsl:if>
+    </xsl:for-each>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+</src:fragment>
+
+</section>
+<section><title>Fragments</title>
+
+<src:fragment id="topfragment">
+<xsl:template match="src:topfragment">
+  <src:fragment id="{@id}">
+    <xsl:choose>
+      <xsl:when test="node()[1] = '&#xA;'">
+        <xsl:apply-templates select="node()[position()&gt;1 and position()&lt;last()]" mode="copy"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates select="node()[position()&lt;last()]" mode="copy"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </src:fragment>
+</xsl:template>
+</src:fragment>
+
+<src:fragment id="fragment">
+<xsl:template match="src:fragment">
+  <src:fragment id="{@id}">
+    <xsl:choose>
+      <xsl:when test="node()[1] = '&#xA;'">
+        <xsl:apply-templates select="node()[position()&gt;1]" mode="copy"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates select="node()" mode="copy"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </src:fragment>
+</xsl:template>
+</src:fragment>
+
+</section>
+<section><title>Rest</title>
+
+<src:fragment id="rest">
+
+<!-- ============================================================ -->
+
+<xsl:template match="src:fragref">
+  <xsl:variable name="linkend" select="@linkend"/>
+  <src:fragref linkend="{@linkend}" disable-output-escaping="yes">
+    <xsl:apply-templates/>
+  </src:fragref>
+</xsl:template>
+
+<!-- ============================================================ -->
+
+<xsl:template match="*" mode="copy" priority="2">
+  <xsl:variable name="name" select="name(.)"/>
+  <xsl:variable name="prevtext" select="preceding-sibling::text()"/>
+  <xsl:variable name="exclude">
+    <xsl:choose>
+      <xsl:when test="ancestor::src:fragment/@exclude-result-prefixes">
+        <xsl:value-of select="concat(' xml ',
+                              ancestor::src:fragment/@exclude-result-prefixes,
+                              ' ')"/>
+      </xsl:when>
+      <xsl:when test="ancestor::src:topfragment">
+        <xsl:value-of select="concat(' xml ',
+                              ancestor::src:top-fragment/@exclude-result-prefixes,
+                              ' ')"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="concat(' xml ',
+                              $default-exclude-result-prefixes,
+                              ' ')"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:text>&lt;</xsl:text>
+  <xsl:value-of select="name(.)"/>
+
+  <xsl:variable name="applicable.namespaces">
+    <xsl:call-template name="count.applicable.namespaces">
+      <xsl:with-param name="namespaces" select="namespace::*"/>
+      <xsl:with-param name="exclude-prefixes" select="$exclude"/>
+      <xsl:with-param name="exclude-uri"
+                      select="'http://nwalsh.com/xmlns/litprog/fragment'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:if test="$applicable.namespaces &gt; 0">
+    <xsl:call-template name="output.applicable.namespaces">
+      <xsl:with-param name="namespaces" select="namespace::*"/>
+      <xsl:with-param name="exclude-prefixes" select="$exclude"/>
+      <xsl:with-param name="exclude-uri"
+                      select="'http://nwalsh.com/xmlns/litprog/fragment'"/>
+    </xsl:call-template>
+  </xsl:if>
+
+  <xsl:choose>
+    <xsl:when test="$applicable.namespaces &gt; 0">
+      <xsl:call-template name="output.applicable.attributes">
+        <xsl:with-param name="attributes" select="attribute::*"/>
+        <xsl:with-param name="first" select="'0'"/>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:call-template name="output.applicable.attributes">
+        <xsl:with-param name="attributes" select="attribute::*"/>
+      </xsl:call-template>
+    </xsl:otherwise>
+  </xsl:choose>
+
+  <xsl:text>&gt;</xsl:text>
+  <xsl:apply-templates select="node()" mode="copy"/>
+  <xsl:text>&lt;/</xsl:text>
+  <xsl:value-of select="name(.)"/>
+  <xsl:text>&gt;</xsl:text>
+</xsl:template>
+
+<xsl:template match="src:passthrough" mode="copy" priority="3">
+  <xsl:apply-templates select="node()|@*" mode="copy"/>
+</xsl:template>
+
+<xsl:template match="src:comment" mode="copy" priority="3">
+  <xsl:text>&lt;!--</xsl:text>
+    <xsl:apply-templates select="node()|@*" mode="copy"/>
+  <xsl:text>--&gt;</xsl:text>
+</xsl:template>
+
+<xsl:template match="src:fragref" mode="copy" priority="3">
+  <xsl:variable name="linkend" select="@linkend"/>
+  <xsl:choose>
+    <xsl:when test="@disable-output-escaping='yes'">
+      <xsl:text>&lt;src:fragref linkend="</xsl:text>
+      <xsl:value-of select="@linkend"/>
+      <xsl:text>"/&gt;</xsl:text>
+      <xsl:apply-templates mode="copy"/>
+      <xsl:text>&lt;/src:fragref&gt;</xsl:text>
+    </xsl:when>
+    <xsl:otherwise>
+      <xref linkend="{@linkend}"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template name="indent">
+  <xsl:param name="name" select="name(.)"/>
+  <xsl:param name="prevtext" select="preceding-sibling::text()"/>
+
+  <xsl:variable name="namelen" select="string-length($name)"/>
+  <xsl:call-template name="spaces">
+    <xsl:with-param name="count" select="$namelen + 1"/>
+  </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="spaces">
+  <xsl:param name="count" select="'0'"/>
+  <xsl:if test="$count &gt; 0">
+    <xsl:text> </xsl:text>
+    <xsl:call-template name="spaces">
+      <xsl:with-param name="count" select="$count - 1"/>
+    </xsl:call-template>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="count.applicable.namespaces">
+  <xsl:param name="namespaces" select="namespace::*"/>
+  <xsl:param name="exclude-prefixes" select="''"/>
+  <xsl:param name="exclude-uri"
+             select="'http://nwalsh.com/xmlns/litprog/fragment'"/>
+  <xsl:param name="count" select="'0'"/>
+
+<!--
+  <xsl:message>
+    <xsl:text>ns: </xsl:text>
+    <xsl:value-of select="name(.)"/>
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="$count"/>
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="count($namespaces)"/>
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="name($namespaces[1])"/>
+    <xsl:text>=</xsl:text>
+    <xsl:value-of select="$namespaces[1]"/>
+    <xsl:choose>
+      <xsl:when test="not(contains($exclude-prefixes, name($namespaces[1]))
+                      or ($namespaces[1] = $exclude-uri))"> 1</xsl:when>
+      <xsl:otherwise> 0</xsl:otherwise>
+    </xsl:choose>
+  </xsl:message>
+-->
+
+  <xsl:choose>
+    <xsl:when test="count($namespaces) = 0">
+      <xsl:value-of select="$count"/>
+    </xsl:when>
+
+    <xsl:when test="not(contains($exclude-prefixes, name($namespaces[1]))
+                        or ($namespaces[1] = $exclude-uri))">
+      <xsl:call-template name="count.applicable.namespaces">
+        <xsl:with-param name="namespaces"
+                        select="$namespaces[position()&gt;1]"/>
+        <xsl:with-param name="exclude-prefixes" select="$exclude-prefixes"/>
+        <xsl:with-param name="exclude-uri" select="$exclude-uri"/>
+        <xsl:with-param name="count" select="$count + 1"/>
+      </xsl:call-template>
+    </xsl:when>
+
+    <xsl:otherwise>
+      <xsl:call-template name="count.applicable.namespaces">
+        <xsl:with-param name="namespaces"
+                        select="$namespaces[position()&gt;1]"/>
+        <xsl:with-param name="exclude-prefixes" select="$exclude-prefixes"/>
+        <xsl:with-param name="exclude-uri" select="$exclude-uri"/>
+        <xsl:with-param name="count" select="$count"/>
+      </xsl:call-template>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template name="output.applicable.namespaces">
+  <xsl:param name="namespaces" select="namespace::*"/>
+  <xsl:param name="exclude-prefixes" select="''"/>
+  <xsl:param name="exclude-uri"
+             select="'http://nwalsh.com/xmlns/litprog/fragment'"/>
+  <xsl:param name="first" select="'1'"/>
+
+<!--
+  <xsl:message>
+    <xsl:text>ons: </xsl:text>
+    <xsl:value-of select="name(.)"/>
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="$first"/>
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="count($namespaces)"/>
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="name($namespaces[1])"/>
+    <xsl:text>=</xsl:text>
+    <xsl:value-of select="$namespaces[1]"/>
+    <xsl:choose>
+      <xsl:when test="not(contains($exclude-prefixes, name($namespaces[1]))
+                      or ($namespaces[1] = $exclude-uri))"> 1</xsl:when>
+      <xsl:otherwise> 0</xsl:otherwise>
+    </xsl:choose>
+  </xsl:message>
+-->
+
+  <xsl:choose>
+    <xsl:when test="count($namespaces) = 0"/>
+    <xsl:when test="not(contains($exclude-prefixes, name($namespaces[1]))
+                        or ($namespaces[1] = $exclude-uri))">
+      <xsl:choose>
+        <xsl:when test="$first = 0">
+          <xsl:text>&#xA;</xsl:text>
+          <xsl:call-template name="indent"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:text> </xsl:text>
+        </xsl:otherwise>
+      </xsl:choose>
+      <xsl:text>xmlns</xsl:text>
+      <xsl:if test="name($namespaces[1]) != ''">:</xsl:if>
+      <xsl:value-of select="name($namespaces[1])"/>
+      <xsl:text>="</xsl:text>
+      <xsl:value-of select="$namespaces[1]"/>
+      <xsl:text>"</xsl:text>
+      <xsl:call-template name="output.applicable.namespaces">
+        <xsl:with-param name="namespaces"
+                        select="$namespaces[position()&gt;1]"/>
+        <xsl:with-param name="exclude-prefixes" select="$exclude-prefixes"/>
+        <xsl:with-param name="exclude-uri" select="$exclude-uri"/>
+        <xsl:with-param name="first" select="0"/>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:call-template name="output.applicable.namespaces">
+        <xsl:with-param name="namespaces"
+                        select="$namespaces[position()&gt;1]"/>
+        <xsl:with-param name="exclude-prefixes" select="$exclude-prefixes"/>
+        <xsl:with-param name="exclude-uri" select="$exclude-uri"/>
+        <xsl:with-param name="count" select="$first"/>
+      </xsl:call-template>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template name="output.applicable.attributes">
+  <xsl:param name="attributes" select="attribute::*"/>
+  <xsl:param name="first" select="'1'"/>
+
+<!--
+  <xsl:message>
+    <xsl:text>att: </xsl:text>
+    <xsl:value-of select="$first"/>
+    <xsl:value-of select="count($attributes)"/>
+    <xsl:value-of select="name($attributes[1])"/>
+  </xsl:message>
+-->
+
+  <xsl:choose>
+    <xsl:when test="count($attributes) = 0"/>
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="$first = 0">
+          <xsl:text>&#xA;</xsl:text>
+          <xsl:call-template name="indent"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:text> </xsl:text>
+        </xsl:otherwise>
+      </xsl:choose>
+      <xsl:value-of select="name($attributes[1])"/>
+      <xsl:text>="</xsl:text>
+      <xsl:value-of select="$attributes[1]"/>
+      <xsl:text>"</xsl:text>
+      <xsl:call-template name="output.applicable.attributes">
+        <xsl:with-param name="attributes"
+                        select="$attributes[position()&gt;1]"/>
+        <xsl:with-param name="first" select="'0'"/>
+      </xsl:call-template>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="node()|@*" mode="copy">
+  <xsl:copy>
+    <xsl:apply-templates select="@*|node()" mode="copy"/>
+  </xsl:copy>
+</xsl:template>
+
+<!-- ============================================================ -->
+</src:fragment>
+
+</section>
+
+</article>